Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Bumber64 authored Mar 7, 2024
2 parents 9df77a7 + d0148fb commit efa0913
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 75 deletions.
11 changes: 9 additions & 2 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,30 @@ Template for new versions:

## New Tools
- `fix/stuck-worship`: fix prayer so units don't get stuck in uninterruptible "Worship!" states
- `instruments`: provides information on how to craft the instruments used by the player civilization.
- `gui/mechanisms`: unlink and free mechanisms from buildings

## New Features
- `gui/settings-manager`: add import, export, and autoload for work details

## Fixes
- `gui/notify`: persist notification settings when toggled in the UI
- `gui/launcher`: fix history scanning (Up/Down arrow keys) being slow to respond when in minimal mode

## Misc Improvements
- `gui/launcher`: add interface for browsing and filtering commands by tags
- `gui/launcher`: add support for history search (Alt-s hotkey) when in minimal mode
- `gui/launcher`: developer mode hotkey restored to Ctrl-D
- `exterminate`: make race name matching case and space insensitive

## Removed

# 50.12-r1

## Fixes
- `gui/notify`: persist notification settings when toggled in the UI

## Misc Improvements
- `gui/launcher`: developer mode hotkey restored to Ctrl-D

# 50.11-r7

## New Tools
Expand Down
5 changes: 0 additions & 5 deletions devel/check-release.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
-- basic check for release readiness
--[====[
devel/check-release
===================
Basic checks for release readiness
]====]

local ok = true
function err(s)
Expand Down
46 changes: 28 additions & 18 deletions docs/ban-cooking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ ban-cooking

Some cookable ingredients have other important uses. For example, seeds can be
cooked, but if you cook them all, then your farmers will have nothing to plant
in the fields. Similarly, thread can be cooked, but if you do that, then your
weavers will have nothing to weave into cloth and your doctors will have
nothing to use for stitching up injured dwarves.
in the fields. Similarly, booze can be cooked, but if you do that, then your
dwarves will have nothing (good) to drink.

If you open the Kitchen screen, you can select individual item types and choose
to ban them from cooking. To prevent all your booze from being cooked, for
example, you'd select the Booze tab and then click each of the visible types of
example, you'd filter by "Drinks" and then click each of the visible types of
booze to prevent them from being cooked. Only types that you have in stock are
shown, so if you acquire a different type of booze in the future, you have to
come back to this screen and ban the new types.
Expand All @@ -23,12 +22,12 @@ items (e.g. all types of booze) in one go. It can even ban types that you don't
have in stock yet, so when you *do* get some in stock, they will already be
banned. It will never ban items that are only good for eating or cooking, like
meat or non-plantable nuts. It is usually a good idea to run
``ban-cooking all`` as one of your first actions in a new fort.
``ban-cooking all`` as one of your first actions in a new fort. You can add
this command to your Autostart list in `gui/control-panel`.

If you want to re-enable cooking for a banned item type, you can go to the
Kitchen screen and un-ban whatever you like by clicking on the "cook"
icon. You can also un-ban an entire class of items with the
``ban-cooking --unban`` option.
icon. You can also un-ban an entire class of items with the ``--unban`` option.

Usage
-----
Expand All @@ -37,20 +36,31 @@ Usage

ban-cooking <type|all> [<type> ...] [<options>]

Valid types are ``booze``, ``brew`` (brewable plants), ``fruit``, ``honey``,
``milk``, ``mill`` (millable plants), ``oil``, ``seeds`` (plantable seeds),
``tallow``, and ``thread``. It is possible to include multiple types or all
types in a single ban-cooking command: ``ban-cooking oil tallow`` will ban both
oil and tallow from cooking. ``ban-cooking all`` will ban all of the above
types.
Valid types are:

Examples::
- ``booze``
- ``brew`` (brewable plants)
- ``fruit``
- ``honey``
- ``milk``
- ``mill`` (millable plants)
- ``oil``
- ``seeds`` (plantable seeds)
- ``tallow``
- ``thread``

on-new-fortress ban-cooking all
Note that in the vanilla game, there are no items that can be milled or turned
into thread that can also be cooked, so these types are only useful when using
mods that add such items to the game.

Ban cooking all otherwise useful ingredients once when starting a new fortress.
Note that this exact command can be enabled via the ``Autostart`` tab of
`gui/control-panel`.
Examples
--------

``ban-cooking oil tallow``
Ban all types of oil and tallow from cooking.
``ban-cooking all``
Ban all otherwise useful types of foods from being cooked. This command can
be enabled for Autostart in `gui/control-panel`.

Options
-------
Expand Down
9 changes: 4 additions & 5 deletions docs/gui/launcher.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,10 @@ setting the tag filter with :kbd:`Ctrl`:kbd:`W` or by clicking on the ``Tags``
button. If the first word of what you've typed matches a valid command, then the
autocomplete options switch to showing commands that have similar functionality
to the one that you've typed. Click on an autocomplete list option to select it
or cycle through them with :kbd:`Shift`:kbd:`Left` and
:kbd:`Shift`:kbd:`Right`. You can run a command quickly without parameters by
double-clicking on the tool name in the list. Holding down shift while you
double-click allows you to run the command and close `gui/launcher` at the same
time.
or cycle through them with :kbd:`Tab` and :kbd:`Shift`:kbd:`Tab`. You can run a
command quickly without parameters by double-clicking on the tool name in the
list. Holding down shift while you double-click allows you to run the command
and close `gui/launcher` at the same time.

Context-sensitive help and command output
-----------------------------------------
Expand Down
20 changes: 20 additions & 0 deletions docs/instruments.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
instruments
===========

.. dfhack-tool::
:summary: Show how to craft instruments.
:tags: fort inspection

This tool provides information on how to craft the instruments used by the
player civilization. For single-piece instruments, it shows the skill and
material needed to craft it. For multi-piece instruments, it displays the skill
used in its assembly as well as information on how to craft the necessary
pieces. It also shows whether the instrument is handheld or placed as a
building.

Usage
-----

::

instruments
2 changes: 1 addition & 1 deletion docs/necronomicon.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ necronomicon

.. dfhack-tool::
:summary: Find books that contain the secrets of life and death.
:tags: fort inspection productivity items
:tags: fort inspection items

Lists all books in the fortress that contain the secrets to life and death.
To find the books in fortress mode, go to the Written content submenu in
Expand Down
68 changes: 30 additions & 38 deletions gui/autobutcher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,31 +144,17 @@ local function sort_by_ordered_asc(a, b)
return a.ordered < b.ordered
end

function nextAutowatchState()
if plugin.autowatch_isEnabled() then
return 'Stop '
end
return 'Start'
end

function nextAutobutcherState()
if plugin.isEnabled() then
return 'Stop '
end
return 'Start'
end

function WatchList:init()
if plugin.isEnabled() then
-- ensure slaughter counts and autowatch are up to date
dfhack.run_command('autobutcher', 'now')
end

local window = widgets.Window{
frame_title = 'Autobutcher Watchlist',
frame = { w=97, h=30 },
resizable = true,
subviews = {
frame_title='Autobutcher',
frame={w=97, h=30},
resizable=true,
subviews={
widgets.CycleHotkeyLabel{
view_id='sort',
frame={l=0, t=0, w=31},
Expand Down Expand Up @@ -416,19 +402,29 @@ function WatchList:init()
auto_width=true,
on_activate=self:callback('onSetRow'),
},
widgets.HotkeyLabel{
frame={t=5, l=0},
widgets.ToggleHotkeyLabel{
view_id='enable_toggle',
frame={t=5, l=0, w=26},
label='Autobutcher is',
key='CUSTOM_SHIFT_A',
label=function() return nextAutobutcherState() .. ' Autobutcher' end,
auto_width=true,
on_activate=self:callback('onToggleAutobutcher'),
options={{value=true, label='Enabled', pen=COLOR_GREEN},
{value=false, label='Disabled', pen=COLOR_RED}},
on_change=function(val)
plugin.setEnabled(val)
self:refresh()
end,
},
widgets.HotkeyLabel{
frame={t=5, l=24},
widgets.ToggleHotkeyLabel{
view_id='autowatch_toggle',
frame={t=5, l=43, w=24},
label='Autowatch is',
key='CUSTOM_SHIFT_W',
label=function() return nextAutowatchState() .. ' Autowatch' end,
auto_width=true,
on_activate=self:callback('onToggleAutowatch'),
options={{value=true, label='Enabled', pen=COLOR_GREEN},
{value=false, label='Disabled', pen=COLOR_RED}},
on_change=function(val)
plugin.autowatch_setEnabled(val)
self:refresh()
end,
},
},
},
Expand All @@ -439,6 +435,12 @@ function WatchList:init()
self:refresh()
end

function WatchList:onRenderFrame(dc, rect)
self.subviews.enable_toggle:setOption(plugin.isEnabled())
self.subviews.autowatch_toggle:setOption(plugin.autowatch_isEnabled())
WatchList.super.onRenderFrame(self, dc, rect)
end

function stringify(number)
if not number then return '' end
-- cap displayed number to 2 characters to fit in the column width
Expand Down Expand Up @@ -707,16 +709,6 @@ function WatchList:onButcherRace()
self:refresh()
end

function WatchList:onToggleAutobutcher()
plugin.setEnabled(not plugin.isEnabled())
self:refresh()
end

function WatchList:onToggleAutowatch()
plugin.autowatch_setEnabled(not plugin.autowatch_isEnabled())
self:refresh()
end

function WatchList:onDismiss()
view = nil
end
Expand Down
8 changes: 4 additions & 4 deletions gui/launcher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ function AutocompletePanel:init()
},
widgets.Label{
frame={l=1, t=1},
text={{text='Shift+Left', pen=COLOR_LIGHTGREEN},
text={{text='Tab', pen=COLOR_LIGHTGREEN},
{text='/'},
{text='Shift+Right', pen=COLOR_LIGHTGREEN}}
{text='Shift+Tab', pen=COLOR_LIGHTGREEN}}
},
widgets.Label{
frame={l=0, t=3},
Expand Down Expand Up @@ -783,9 +783,9 @@ function MainPanel:onInput(keys)
elseif keys.CUSTOM_CTRL_D then
toggle_dev_mode()
self:refresh_autocomplete()
elseif keys.KEYBOARD_CURSOR_RIGHT_FAST then
elseif keys.CHANGETAB then
self.subviews.autocomplete:advance(1)
elseif keys.KEYBOARD_CURSOR_LEFT_FAST then
elseif keys.SEC_CHANGETAB then
self.subviews.autocomplete:advance(-1)
else
return false
Expand Down
6 changes: 4 additions & 2 deletions gui/mod-manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ local utils = require('utils')
local presets_file = json.open("dfhack-config/mod-manager.json")
local GLOBAL_KEY = 'mod-manager'

local function get_newregion_viewscreen()
-- get_newregion_viewscreen and get_modlist_fields are declared as global functions
-- so external tools can call them to get the DF mod list
function get_newregion_viewscreen()
local vs = dfhack.gui.getViewscreenByType(df.viewscreen_new_regionst, 0)
return vs
end

local function get_modlist_fields(kind, viewscreen)
function get_modlist_fields(kind, viewscreen)
if kind == "available" then
return {
id = viewscreen.available_id,
Expand Down
70 changes: 70 additions & 0 deletions instruments.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
-- civilization ID of the player civilization
local civ_id = df.global.plotinfo.civ_id

---@type instrument itemdef_instrumentst
---@return reaction|nil
function getAssemblyReaction(instrument)
for _, reaction in ipairs(df.global.world.raws.reactions.reactions) do
if reaction.source_enid == civ_id and
reaction.category == 'INSTRUMENT' and
reaction.name:find(instrument.name, 1, true)
then
return reaction
end
end
return nil
end

-- patch in thread type
---@type reagent reaction_reagent_itemst
---@return string
function reagentString(reagent)
if reagent.code == 'thread' then
local silk = reagent.flags2.silk and "silk " or ""
local yarn = reagent.flags2.yarn and "yarn " or ""
local plant = reagent.flags2.plant and "plant " or ""
return silk..yarn..plant.."thread"
else
return reagent.code
end
end

---@type reaction reaction
---@return string
function describeReaction(reaction)
local skill = df.job_skill[reaction.skill]
local reagents = {}
for _, reagent in ipairs(reaction.reagents) do
table.insert(reagents, reagentString(reagent))
end
return skill .. ": " .. table.concat(reagents, ", ")
end

-- gather instrument piece reactions and index them by the instrument they are part of
local instruments = {}
for _, reaction in ipairs(df.global.world.raws.reactions.reactions) do
if reaction.source_enid == civ_id and reaction.category == 'INSTRUMENT_PIECE' then
local iname = reaction.name:match("[^ ]+ ([^ ]+)")
table.insert(ensure_key(instruments, iname),
reaction.name.." ("..describeReaction(reaction)..")")
end
end

-- go over instruments
for _,instrument in ipairs(df.global.world.raws.itemdefs.instruments) do
if not (instrument.source_enid == civ_id) then goto continue end

local building_tag = instrument.flags.PLACED_AS_BUILDING and " (building, " or " (handheld, "
local reaction = getAssemblyReaction(instrument)
dfhack.print(instrument.name..building_tag)
if #instrument.pieces == 0 then
print(describeReaction(reaction)..")")
else
print(df.job_skill[reaction.skill].."/assemble)")
for _,str in pairs(instruments[instrument.name]) do
print(" "..str)
end
end
print()
::continue::
end

0 comments on commit efa0913

Please sign in to comment.