Skip to content

Commit

Permalink
Merge pull request #1280 from myk002/myk_zones
Browse files Browse the repository at this point in the history
[quickfort] integrate with preserve-rooms
  • Loading branch information
myk002 authored Aug 30, 2024
2 parents 3444064 + 07759c2 commit fe19564
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Template for new versions:
- `caravan`: DFHack dialogs for trade screens (both ``Bring goods to depot`` and the ``Trade`` barter screen) can now filter by item origins (foreign vs. fort-made) and can filter bins by whether they have a mix of ethically acceptable and unacceptable items in them
- `caravan`: If you have managed to select an item that is ethically unacceptable to the merchant, an "Ethics warning" badge will now appear next to the "Trade" button. Clicking on the badge will show you which items that you have selected are problematic. The dialog has a button that you can click to deselect the problematic items in the trade list.
- `confirm`: If you have ethically unacceptable items selected for trade, the "Are you sure you want to trade" confirmation will warn you about them
- `quickfort`: ``#zone`` blueprints now integrated with `preserve-rooms` so you can create a zone and automatically assign it to a noble or administrative role

## Fixes
- `timestream`: ensure child growth events (e.g. becoming an adult) are not skipped over
Expand Down
4 changes: 2 additions & 2 deletions gui/quickfort.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function BlueprintDialog:init()
text_pen=COLOR_GREY,
},
widgets.ToggleHotkeyLabel{
frame={t=0, l=12},
frame={t=0, l=12, w=20},
key='CUSTOM_ALT_L',
label='Library:',
options=options,
Expand All @@ -72,7 +72,7 @@ function BlueprintDialog:init()
on_change=self:callback('update_setting', 'show_library')
},
widgets.ToggleHotkeyLabel{
frame={t=0, l=35},
frame={t=0, l=35, w=19},
key='CUSTOM_ALT_H',
label='Hidden:',
options=options,
Expand Down
26 changes: 8 additions & 18 deletions internal/quickfort/zone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ if not dfhack_flags.module then
end

require('dfhack.buildings') -- loads additional functions into dfhack.buildings
local utils = require('utils')
local preserve_rooms = require('plugins.preserve-rooms')
local quickfort_common = reqscript('internal/quickfort/common')
local quickfort_building = reqscript('internal/quickfort/building')
local quickfort_parse = reqscript('internal/quickfort/parse')
local utils = require('utils')

local log = quickfort_common.log
local logfn = quickfort_common.logfn
Expand Down Expand Up @@ -227,12 +228,6 @@ local function parse_location_props(props)
return location_data
end

local function get_noble_unit(noble)
local unit = dfhack.units.getUnitByNobleRole(noble)
if not unit then log('could not find a noble position for: "%s"', noble) end
return unit
end

local function parse_zone_config(c, props)
if not rawget(zone_db_raw, c) then
return 'Invalid', nil
Expand All @@ -250,13 +245,7 @@ local function parse_zone_config(c, props)
props.name = nil
end
if props.assigned_unit then
zone_data.assigned_unit = get_noble_unit(props.assigned_unit)
if not zone_data.assigned_unit and props.assigned_unit:lower() == 'sheriff' then
zone_data.assigned_unit = get_noble_unit('captain_of_the_guard')
end
if not zone_data.assigned_unit then
log('could not find a unit assigned to noble position: "%s"', props.assigned_unit)
end
zone_data.assigned_unit = props.assigned_unit
props.assigned_unit = nil
end
if db_entry.props_fn then db_entry.props_fn(zone_data, props) end
Expand Down Expand Up @@ -387,11 +376,12 @@ local function create_zone(zone, data, ctx)
set_location(bld, data.location, ctx)
data.location = nil
end
if data.assigned_unit then
dfhack.buildings.setOwner(bld, data.assigned_unit)
data.assigned_unit = nil
end
local assigned_unit = data.assigned_unit
data.assigned_unit = nil
utils.assign(bld, data)
if assigned_unit then
preserve_rooms.assignToRole(assigned_unit, bld)
end
return ntiles
end

Expand Down

0 comments on commit fe19564

Please sign in to comment.