Skip to content

Commit 62ad45d

Browse files
Merge remote-tracking branch 'upstream/master' into SquidHack
2 parents af18805 + 4a950bd commit 62ad45d

File tree

12 files changed

+1177
-109
lines changed

12 files changed

+1177
-109
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ repos:
2020
args: ['--fix=lf']
2121
- id: trailing-whitespace
2222
- repo: https://github.com/python-jsonschema/check-jsonschema
23-
rev: 0.33.0
23+
rev: 0.33.2
2424
hooks:
2525
- id: check-github-workflows
2626
- repo: https://github.com/Lucas-C/pre-commit-hooks

ban-cooking.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ end
8181

8282
funcs.honey = function()
8383
local mat = dfhack.matinfo.find("CREATURE:HONEY_BEE:HONEY")
84-
ban_cooking('honey bee honey', mat.type, mat.index, df.item_type.LIQUID_MISC, -1)
84+
if mat then
85+
ban_cooking('honey bee honey', mat.type, mat.index, df.item_type.LIQUID_MISC, -1)
86+
end
8587
end
8688

8789
funcs.tallow = function()

changelog.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,28 @@ Template for new versions:
2929
## New Tools
3030
- `autotraining`: new tool to assign citizens to a military squad when they need Martial Training
3131
- `gui/autotraining`: configuration tool for autotraining
32+
- `entomb`: allow any unit that has a corpse or body parts to be assigned a tomb zone
33+
34+
- `husbandry`: Automatically milk and shear animals at nearby farmer's workshops
3235

3336
## New Features
3437
- `deathcause`: added functionality to this script to fetch cause of death programatically
3538

3639
## Fixes
37-
40+
- `ban-cooking`: will not fail trying to ban honey if the world has no honey
41+
- `confirm`: only show pause option for pausable confirmations
42+
- `confirm`: when editing a uniform, confirm discard of changes when exiting with Escape
43+
- `confirm`: when removing a manager order, show correct order description when using non-100% interface setting
44+
- `confirm`: when removing a manager order, show correct order description after prior order removal or window resize (when scrolled to bottom of order list)
45+
- `confirm`: when removing a manager order, show specific item/job type for ammo, shield, helm, gloves, shoes, trap component, and meal orders
46+
- `confirm`: the pause option now pauses individual confirmation types, allowing multiple different confirmations to be paused independently
3847
- `immortal-cravings`: prioritize high-value meals, properly split of portions, and don't go eating or drinking on a full stomach
48+
- `uniform-unstick`: no longer causes units to equip multiples of assigned items
49+
- `caravan`: in the pedestal item assignment dialog, add new items at the end of the list of displayed items instead of at a random position
50+
- `caravan`: in the pedestal item assignment dialog, consistently remove items from the list of displayed items
3951

4052
## Misc Improvements
53+
- `devel/hello-world`: updated to show off the new Slider widget
4154

4255
## Removed
4356

confirm.lua

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ function ConfirmOverlay:init()
6363
}
6464
end
6565
end
66+
self.paused_confs = {}
6667
end
6768

6869
function ConfirmOverlay:preUpdateLayout()
@@ -77,11 +78,14 @@ function ConfirmOverlay:preUpdateLayout()
7778
end
7879

7980
function ConfirmOverlay:overlay_onupdate()
80-
if self.paused_conf and
81-
not dfhack.gui.matchFocusString(self.paused_conf.context,
81+
for conf in pairs(self.paused_confs) do
82+
if not dfhack.gui.matchFocusString(conf.context,
8283
dfhack.gui.getDFViewscreen(true))
83-
then
84-
self.paused_conf = nil
84+
then
85+
self.paused_confs[conf] = nil
86+
end
87+
end
88+
if not next(self.paused_confs) then
8589
self.overlay_onupdate_max_freq_seconds = 300
8690
end
8791
end
@@ -108,19 +112,22 @@ function ConfirmOverlay:matches_conf(conf, keys, scr)
108112
end
109113

110114
function ConfirmOverlay:onInput(keys)
111-
if self.paused_conf or self.simulating then
115+
if self.simulating then
112116
return false
113117
end
114118
local scr = dfhack.gui.getDFViewscreen(true)
115119
for id, conf in pairs(specs.REGISTRY) do
116120
if specs.config.data[id].enabled and self:matches_conf(conf, keys, scr) then
121+
if self.paused_confs[conf] then
122+
return false
123+
end
117124
local mouse_pos = xy2pos(dfhack.screen.getMousePos())
118125
local propagate_fn = function(pause)
119126
if conf.on_propagate then
120127
conf.on_propagate()
121128
end
122129
if pause then
123-
self.paused_conf = conf
130+
self.paused_confs[conf] = true
124131
self.overlay_onupdate_max_freq_seconds = 0
125132
end
126133
if keys._MOUSE_L then
@@ -131,8 +138,9 @@ function ConfirmOverlay:onInput(keys)
131138
gui.simulateInput(scr, keys)
132139
self.simulating = false
133140
end
141+
local pause_fn = conf.pausable and curry(propagate_fn, true) or nil
134142
dialogs.showYesNoPrompt(conf.title, utils.getval(conf.message):wrap(45), COLOR_YELLOW,
135-
propagate_fn, nil, curry(propagate_fn, true), curry(dfhack.run_script, 'gui/confirm', tostring(conf.id)))
143+
propagate_fn, nil, pause_fn, curry(dfhack.run_script, 'gui/confirm', tostring(conf.id)))
136144
return true
137145
end
138146
end

devel/hello-world.lua

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,27 @@ local HIGHLIGHT_PEN = dfhack.pen.parse{
1212

1313
HelloWorldWindow = defclass(HelloWorldWindow, widgets.Window)
1414
HelloWorldWindow.ATTRS{
15-
frame={w=20, h=14},
15+
frame={w=25, h=25},
1616
frame_title='Hello World',
1717
autoarrange_subviews=true,
18-
autoarrange_gap=1,
18+
autoarrange_gap=2,
19+
resizable=true,
20+
resize_min={w=25, h=25},
1921
}
2022

2123
function HelloWorldWindow:init()
24+
local LEVEL_OPTIONS = {
25+
{label='Low', value=1},
26+
{label='Medium', value=2},
27+
{label='High', value=3},
28+
{label='Pro', value=4},
29+
{label='Insane', value=5},
30+
}
31+
2232
self:addviews{
2333
widgets.Label{text={{text='Hello, world!', pen=COLOR_LIGHTGREEN}}},
2434
widgets.HotkeyLabel{
25-
frame={l=0, t=0},
35+
frame={l=0},
2636
label='Click me',
2737
key='CUSTOM_CTRL_A',
2838
on_activate=self:callback('toggleHighlight'),
@@ -32,6 +42,28 @@ function HelloWorldWindow:init()
3242
frame={w=10, h=5},
3343
frame_style=gui.INTERIOR_FRAME,
3444
},
45+
widgets.Divider{
46+
frame={h=1},
47+
frame_style_l=false,
48+
frame_style_r=false,
49+
},
50+
widgets.CycleHotkeyLabel{
51+
view_id='level',
52+
frame={l=0, w=20},
53+
label='Level:',
54+
key_back='CUSTOM_SHIFT_C',
55+
key='CUSTOM_SHIFT_V',
56+
options=LEVEL_OPTIONS,
57+
initial_option=LEVEL_OPTIONS[1].value,
58+
},
59+
widgets.Slider{
60+
frame={l=1},
61+
num_stops=#LEVEL_OPTIONS,
62+
get_idx_fn=function()
63+
return self.subviews.level:getOptionValue()
64+
end,
65+
on_change=function(idx) self.subviews.level:setOption(idx) end,
66+
},
3567
}
3668
end
3769

docs/entomb.rst

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
entomb
2+
======
3+
4+
.. dfhack-tool::
5+
:summary: Entomb any corpse into tomb zones.
6+
:tags: fort items buildings
7+
8+
Assign any unit regardless of citizenship, residency, pet status,
9+
or affiliation to an unassigned tomb zone for burial.
10+
11+
Usage
12+
-----
13+
14+
``entomb [<options>]``
15+
16+
Select a unit's corpse or body part, or specify the unit's ID
17+
when executing this script to assign an unassigned tomb zone to
18+
the unit, and flag the unit's corpse as well as any severed body
19+
parts to become valid items for interment.
20+
21+
Optionally, specify the tomb zone's ID to assign a specific tomb
22+
zone to the unit.
23+
24+
A non-citizen, non-resident, or non-pet unit that is still alive
25+
may even be assigned a tomb zone if they have lost any body part
26+
that can be placed inside a tomb, e.g. teeth or severed limbs.
27+
New corpse items after a tomb has already been assigned will not
28+
be properly interred until the script is executed again with the
29+
unit ID specified, or the unit's corpse or any body part selected.
30+
31+
If executed on slaughtered animals, all its butchering returns will
32+
become valid burial items and no longer usable for cooking or crafting.
33+
34+
Examples
35+
--------
36+
37+
``entomb --unit <id>``
38+
Assign an unassigned tomb zone to the unit with the specified ID.
39+
40+
``entomb --tomb <id>``
41+
Assign a tomb zone with the specified ID to the selected corpse
42+
item's unit.
43+
44+
``entomb -u <id> -t <id> -h``
45+
Assign a tomb zone with the specified ID to the unit with the
46+
specified ID and task all its burial items for simultaneous
47+
hauling into the coffin in the tomb zone.
48+
49+
Options
50+
-------
51+
52+
``-u``, ``--unit <id>``
53+
Specify the ID of the unit to be assigned to a tomb zone.
54+
55+
``-t``, ``--tomb <id>``
56+
Specify the ID of the zone into which a unit will be interred.
57+
58+
``-a``, ``--add-item``
59+
Add a selected item, or multiple items at the keyboard cursor's
60+
position to be interred together with a unit. A unit or tomb
61+
zone ID must be specified when calling this option.
62+
63+
``-n``, ``--haul-now``
64+
Task all of the unit's burial items for simultaneous hauling
65+
into the coffin of its assigned tomb zone. This option can be
66+
called even after a tomb zone is already assigned to the unit.

docs/husbandry.rst

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
husbandry
2+
=========
3+
4+
.. dfhack-tool::
5+
:summary: Automatically milk and shear animals.
6+
:tags: fort auto
7+
8+
This tool will automatically create milking and shearing orders at farmer's
9+
workshops. Unlike the ``automilk`` and ``autoshear`` options from the control
10+
panel, which create general work orders for milking and shearing jobs,
11+
``husbandry`` will directly create jobs for individual animals at specific
12+
workshops. This allows milking and shearing jobs to reliably be created at
13+
nearby workshops (e.g. inside the pasture that an animal is assigned to),
14+
minimizing the labor required to re-pasture animals after milking or shearing,
15+
in particular in the case of multiple pastures that are far apart.
16+
17+
18+
Usage
19+
-----
20+
21+
::
22+
23+
enable husbandry
24+
husbandry [status]
25+
husbandry now
26+
husbandry [set|unset] [shearing|milking|roaming|pasture]+
27+
28+
Flags can be set or unset using the command ``husbandry set`` or ``husbandry
29+
unset``. The ``shearing`` and ``milking`` flags (both enabled by default)
30+
control whether shearing or milking jobs are created at all.
31+
32+
Further, ``husbandry`` distinguishes between animals that are assigned to
33+
pastures and those that are "roaming".
34+
35+
If an animal is pastured and the pasture contains at least one workshop with the
36+
appropriate labour (i.e. milking or shearing) enabled, jobs will be created
37+
exclusively at those workshops. If the pasture does not contain a workshop with
38+
the appropriate labor enabled the behavior depends on the ``pasture`` flag
39+
(disabled by default): if set, no jobs will be created at workshops outside of
40+
pastures, otherwise jobs may be created at the closest workshop in your fort.
41+
42+
For animals that are roaming, jobs will only be created if the ``roaming`` flag
43+
is set, which is the default. In this case, jobs are created at the closest
44+
workshop with the appropriate labours enabled.
45+
46+
Examples
47+
--------
48+
49+
``enable husbandry``
50+
Start generating milking and shearing orders for animals.
51+
52+
``husbandry now``
53+
Run a single cycle, detecting animals that can be milked/sheared an creating
54+
jobs. Does not require the tool to be enabled.
55+
56+
``husbandry unset roaming``
57+
Disable the creation of jobs for roaming animals.
58+
59+
``husbandry set milking shearing pasture``
60+
Create milking and shearing jobs for pastured animals, but only at workshops
61+
inside their pastures.

0 commit comments

Comments
 (0)