Merge pull request #3885 from myk002/myk_buildingplan_cages

[buildingplan] filter cages by whether they are occupied
develop
Myk 2023-10-15 14:50:08 -07:00 committed by GitHub
commit 754a4fb3f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

@ -74,6 +74,7 @@ Template for new versions:
- `orders`: ``recheck`` command now only resets orders that have conditions that can be rechecked - `orders`: ``recheck`` command now only resets orders that have conditions that can be rechecked
- `sort`: added help button for squad assignment search/filter/sort - `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 - `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 ## Documentation
- unavailable tools are no longer listed in the tag indices in the online docs - unavailable tools are no longer listed in the tag indices in the online docs

@ -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) && static_cast<df::item_slabst *>(item)->engraving_type != df::slab_engraving_type::Memorial)
return false; 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)) if (!matchesHeatSafety(item->getMaterial(), item->getMaterialIndex(), heat))
return false; return false;

@ -162,6 +162,10 @@ local function is_slab()
return uibs.building_type == df.building_type.Slab return uibs.building_type == df.building_type.Slab
end end
local function is_cage()
return uibs.building_type == df.building_type.Cage
end
local function is_stairs() local function is_stairs()
return is_construction() return is_construction()
and uibs.building_subtype == df.construction_type.UpDownStair and uibs.building_subtype == df.construction_type.UpDownStair
@ -477,6 +481,16 @@ function PlannerOverlay:init()
buildingplan.setSpecial(uibs.building_type, uibs.building_subtype, uibs.custom_type, 'engraved', val) buildingplan.setSpecial(uibs.building_type, uibs.building_subtype, uibs.custom_type, 'engraved', val)
end, 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{ widgets.Label{
frame={b=4, l=23}, frame={b=4, l=23},
text_pen=COLOR_DARKGREY, text_pen=COLOR_DARKGREY,
@ -847,6 +861,8 @@ function PlannerOverlay:onRenderFrame(dc, rect)
local buildingplan = require('plugins.buildingplan') local buildingplan = require('plugins.buildingplan')
self.subviews.engraved:setOption(buildingplan.getSpecials( self.subviews.engraved:setOption(buildingplan.getSpecials(
uibs.building_type, uibs.building_subtype, uibs.custom_type).engraved or false) 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( self.subviews.choose:setOption(buildingplan.getChooseItems(
uibs.building_type, uibs.building_subtype, uibs.custom_type)) uibs.building_type, uibs.building_subtype, uibs.custom_type))
self.subviews.safety:setOption(buildingplan.getHeatSafetyFilter( self.subviews.safety:setOption(buildingplan.getHeatSafetyFilter(