Skip to content

Commit

Permalink
Merge pull request #3885 from myk002/myk_buildingplan_cages
Browse files Browse the repository at this point in the history
[buildingplan] filter cages by whether they are occupied
  • Loading branch information
myk002 authored Oct 15, 2023
2 parents 84681f1 + 682e9d3 commit 754a4fb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Template for new versions:
- `orders`: ``recheck`` command now only resets orders that have conditions that can be rechecked
- `sort`: added help button for squad assignment search/filter/sort
- `zone`: animals trained for war or hunting are now labeled as such in animal assignment screens
- `buildingplan`: support filtering cages by whether they are occupied

## Documentation
- unavailable tools are no longer listed in the tag indices in the online docs
Expand Down
5 changes: 5 additions & 0 deletions plugins/buildingplan/buildingplan_cycle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ bool matchesFilters(df::item * item, const df::job_item * jitem, HeatSafety heat
&& static_cast<df::item_slabst *>(item)->engraving_type != df::slab_engraving_type::Memorial)
return false;

if (item->getType() == df::item_type::CAGE && specials.count("empty")
&& (Items::getGeneralRef(item, df::general_ref_type::CONTAINS_UNIT)
|| Items::getGeneralRef(item, df::general_ref_type::CONTAINS_ITEM)))
return false;

if (!matchesHeatSafety(item->getMaterial(), item->getMaterialIndex(), heat))
return false;

Expand Down
16 changes: 16 additions & 0 deletions plugins/lua/buildingplan/planneroverlay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ local function is_slab()
return uibs.building_type == df.building_type.Slab
end

local function is_cage()
return uibs.building_type == df.building_type.Cage
end

local function is_stairs()
return is_construction()
and uibs.building_subtype == df.construction_type.UpDownStair
Expand Down Expand Up @@ -477,6 +481,16 @@ function PlannerOverlay:init()
buildingplan.setSpecial(uibs.building_type, uibs.building_subtype, uibs.custom_type, 'engraved', val)
end,
},
widgets.ToggleHotkeyLabel {
view_id='empty',
frame={b=4, l=1, w=22},
key='CUSTOM_T',
label='Empty only:',
visible=is_cage,
on_change=function(val)
buildingplan.setSpecial(uibs.building_type, uibs.building_subtype, uibs.custom_type, 'empty', val)
end,
},
widgets.Label{
frame={b=4, l=23},
text_pen=COLOR_DARKGREY,
Expand Down Expand Up @@ -847,6 +861,8 @@ function PlannerOverlay:onRenderFrame(dc, rect)
local buildingplan = require('plugins.buildingplan')
self.subviews.engraved:setOption(buildingplan.getSpecials(
uibs.building_type, uibs.building_subtype, uibs.custom_type).engraved or false)
self.subviews.empty:setOption(buildingplan.getSpecials(
uibs.building_type, uibs.building_subtype, uibs.custom_type).empty or false)
self.subviews.choose:setOption(buildingplan.getChooseItems(
uibs.building_type, uibs.building_subtype, uibs.custom_type))
self.subviews.safety:setOption(buildingplan.getHeatSafetyFilter(
Expand Down

0 comments on commit 754a4fb

Please sign in to comment.