Skip to content

Commit afcd9c1

Browse files
authored
Merge pull request #1353 from myk002/myk_pedestal
[caravan] add filter for written works
2 parents 0324a19 + 77e91ea commit afcd9c1

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Template for new versions:
3535

3636
## Misc Improvements
3737
- `immortal-cravings`: goblins and other naturally non-eating/non-drinking races will now also satisfy their needs for eating and drinking
38+
- `caravan`: add filter for written works in display furniture assignment dialog
3839

3940
## Removed
4041

docs/caravan.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,9 @@ assignment GUI.
156156
The dialog allows you to sort by name, value, or where the item is currently
157157
assigned for display.
158158

159-
You can search by name, and you can filter by item quality and by whether the
160-
item is forbidden.
159+
You can search by name, and you can filter by:
160+
161+
- item quality
162+
- whether the item is forbidden
163+
- whether the item is reachable from the display furniture
164+
- whether the item is a written work (book or scroll)

internal/caravan/pedestal.lua

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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
554571
end
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+
556578
function 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

Comments
 (0)