diff --git a/changelog.txt b/changelog.txt index 0894d4071..b3f8e5b92 100644 --- a/changelog.txt +++ b/changelog.txt @@ -30,6 +30,8 @@ Template for new versions: - `fix/stuck-squad`: allow squads and messengers returning from missions to rescue squads that have gotten stuck on the world map ## New Features +- `gui/settings-manager`: new overlay on the Labor -> Standing Orders tab for configuring the number of barrels to reserve for job use (so you can brew alcohol and not have all your barrels claimed by stockpiles for container storage) +- `gui/settings-manager`: standing orders save/load now includes the reserved barrels setting ## Fixes diff --git a/docs/gui/settings-manager.rst b/docs/gui/settings-manager.rst index 1c57fe1a6..fd5bec8a5 100644 --- a/docs/gui/settings-manager.rst +++ b/docs/gui/settings-manager.rst @@ -39,10 +39,13 @@ back. You can also toggle an option to automatically load the saved settings for new embarks. When a fort is loaded, you can also go to the Labor -> Standing Orders page. -You will see a new panel that allows you to save and restore your settings for -standing orders. You can also toggle whether the saved standing orders are -automatically restored when you embark on a new fort. This will toggle the -relevant command in `gui/control-panel` on the Automation -> Autostart page. +You will see tow new panels. The first allows you to configure how many barrels +to reserve for use by workshop jobs (instead of being claimed by stockpiles for +container storage). The second panel allows you to save and restore your +settings for standing orders. You can also toggle whether the saved standing +orders are automatically restored when you embark on a new fort. This will +toggle the relevant command in `gui/control-panel` on the Automation -> +Autostart page. There is a similar panel on the Labor -> Work Details page that allows for saving and restoring of work detail definitions. Be aware that work detail diff --git a/gui/settings-manager.lua b/gui/settings-manager.lua index 1a7e468bf..140310c2e 100644 --- a/gui/settings-manager.lua +++ b/gui/settings-manager.lua @@ -2,6 +2,7 @@ local argparse = require('argparse') local control_panel = reqscript('control-panel') +local dialogs = require('gui.dialogs') local gui = require('gui') local json = require('json') local overlay = require('plugins.overlay') @@ -376,7 +377,9 @@ end -- StandingOrdersOverlay -- -local li = df.global.plotinfo.labor_info +local plotinfo = df.global.plotinfo +local li = plotinfo.labor_info +local ps = plotinfo.stockpile local function save_standing_orders() local standing_orders = {} @@ -390,6 +393,7 @@ local function save_standing_orders() chores.enabled = li.flags.children_do_chores chores.labors = utils.clone(li.chores) config.data.chores = chores + config.data.stockpile = {reserved_barrels=ps.reserved_barrels} config:write() end @@ -401,6 +405,10 @@ local function load_standing_orders() for i, val in ipairs(safe_index(config.data.chores, 'labors') or {}) do li.chores[i-1] = val end + local reserved_barrels = safe_index(config.data.stockpile, 'reserved_barrels') + if reserved_barrels then + ps.reserved_barrels = reserved_barrels + end end local function has_saved_standing_orders() @@ -422,6 +430,65 @@ StandingOrdersOverlay.ATTRS { autostart_command='gui/settings-manager load-standing-orders', } +------------------------------ +-- ReservedBarrelsOverlay +-- + +ReservedBarrelsOverlay = defclass(ReservedBarrelsOverlay, overlay.OverlayWidget) +ReservedBarrelsOverlay.ATTRS { + desc='Exposes the setting for reserved barrels on the standing orders screen.', + default_pos={x=59, y=18}, + default_enabled=true, + viewscreens='dwarfmode/Info/LABOR/STANDING_ORDERS/AUTOMATED_WORKSHOPS', + frame={w=26, h=6}, + frame_style=gui.MEDIUM_FRAME, + frame_background=gui.CLEAR_PEN, +} + +function ReservedBarrelsOverlay:init() + self:addviews{ + widgets.Label{ + frame={t=0, l=0}, + text={ + 'Barrels reserved for use', NEWLINE, + 'by workshop jobs: ', + { + text=function() return ps.reserved_barrels end, + pen=function() return ps.reserved_barrels == 0 and COLOR_YELLOW or COLOR_GREEN end, + }, + }, + }, + widgets.HotkeyLabel{ + frame={t=3, l=0}, + key='CUSTOM_CTRL_B', + label='Set num reserved', + on_activate=function() + dialogs.InputBox{ + frame_title='Set reserved barrels', + text={ + 'You can ensure a number of barrels are reserved, preventing', NEWLINE, + 'them from being claimed by stockpiles as container storage.', NEWLINE, + 'For example, if there are 5 reserved barrels, no stockpile', NEWLINE, + 'will claim an empty barrel for storing items until you have', NEWLINE, + 'at least 6 barrels lying around.', NEWLINE, NEWLINE, + 'This feature is most often used to ensure that a fortress has', NEWLINE, + 'ample empty barrels for the production of alcohol, although', NEWLINE, + 'empty barrels are also necessary for other jobs.', + }, + text_pen=COLOR_YELLOW, + label_text='Number of barrels to reserve: ', + input=tostring(ps.reserved_barrels), + on_input=function(input) + input = tonumber(input) + if not input or input < 0 then return end + ps.reserved_barrels = math.floor(input) + end, + }:show() + end, + }, + } +end + ------------------------------ -- WorkDetailsOverlay -- @@ -510,6 +577,7 @@ OVERLAY_WIDGETS = { embark_notification=DifficultyEmbarkNotificationOverlay, settings_difficulty=DifficultySettingsOverlay, standing_orders=StandingOrdersOverlay, + reserved_barrels=ReservedBarrelsOverlay, work_details=WorkDetailsOverlay, }