From e0fdd68f8824a2af050bf4f71769a50d0dd3bfcb Mon Sep 17 00:00:00 2001 From: Mikhail Date: Sat, 16 Sep 2023 14:45:01 +0300 Subject: [PATCH 1/6] Added orders-reevaluate option to request manager orders conditions recheck once per month. --- gui/control-panel.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gui/control-panel.lua b/gui/control-panel.lua index 24689c0c6b..eb3e67b05a 100644 --- a/gui/control-panel.lua +++ b/gui/control-panel.lua @@ -127,6 +127,9 @@ local REPEATS = { ['orders-sort']={ desc='Sort manager orders by repeat frequency so one-time orders can be completed.', command={'--time', '1', '--timeUnits', 'days', '--command', '[', 'orders', 'sort', ']'}}, + ['orders-reevaluate']={ + desc='Invalidates manager orders making it necessary to recheck conditions.', + command={'--time', '1', '--timeUnits', 'months', '--command', '[', 'orders', 'reset', ']'}}, ['warn-starving']={ desc='Show a warning dialog when units are starving or dehydrated.', command={'--time', '10', '--timeUnits', 'days', '--command', '[', 'warn-starving', ']'}}, From c7456909bc0ed5c9d0248f1762921b09a57a3f87 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Mon, 18 Sep 2023 11:44:32 +0300 Subject: [PATCH 2/6] Added 'once a month' clarification to orders-reevaluate. --- gui/control-panel.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/control-panel.lua b/gui/control-panel.lua index eb3e67b05a..8a39294c50 100644 --- a/gui/control-panel.lua +++ b/gui/control-panel.lua @@ -128,7 +128,7 @@ local REPEATS = { desc='Sort manager orders by repeat frequency so one-time orders can be completed.', command={'--time', '1', '--timeUnits', 'days', '--command', '[', 'orders', 'sort', ']'}}, ['orders-reevaluate']={ - desc='Invalidates manager orders making it necessary to recheck conditions.', + desc='Invalidates manager orders once a month making it necessary to recheck conditions.', command={'--time', '1', '--timeUnits', 'months', '--command', '[', 'orders', 'reset', ']'}}, ['warn-starving']={ desc='Show a warning dialog when units are starving or dehydrated.', From bec158e26692100d8a3f77619ae769223d4b4d0e Mon Sep 17 00:00:00 2001 From: Mikhail Date: Mon, 18 Sep 2023 13:42:10 +0300 Subject: [PATCH 3/6] Changed 'reset' to 'recheck'. --- gui/control-panel.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/control-panel.lua b/gui/control-panel.lua index 8a39294c50..bdc5a980cb 100644 --- a/gui/control-panel.lua +++ b/gui/control-panel.lua @@ -129,7 +129,7 @@ local REPEATS = { command={'--time', '1', '--timeUnits', 'days', '--command', '[', 'orders', 'sort', ']'}}, ['orders-reevaluate']={ desc='Invalidates manager orders once a month making it necessary to recheck conditions.', - command={'--time', '1', '--timeUnits', 'months', '--command', '[', 'orders', 'reset', ']'}}, + command={'--time', '1', '--timeUnits', 'months', '--command', '[', 'orders', 'recheck', ']'}}, ['warn-starving']={ desc='Show a warning dialog when units are starving or dehydrated.', command={'--time', '10', '--timeUnits', 'days', '--command', '[', 'warn-starving', ']'}}, From d8acfef36d108bbea0f68a481f54769b6d7873bc Mon Sep 17 00:00:00 2001 From: Mikhail Panov Date: Fri, 22 Sep 2023 18:48:44 +0300 Subject: [PATCH 4/6] Removed workorder-recheck.lua. Work order manager enhancement branch moves it's code to orders.lua plugin. --- gui/control-panel.lua | 2 +- workorder-recheck.lua | 103 ------------------------------------------ 2 files changed, 1 insertion(+), 104 deletions(-) delete mode 100644 workorder-recheck.lua diff --git a/gui/control-panel.lua b/gui/control-panel.lua index bdc5a980cb..fb248e5cc4 100644 --- a/gui/control-panel.lua +++ b/gui/control-panel.lua @@ -128,7 +128,7 @@ local REPEATS = { desc='Sort manager orders by repeat frequency so one-time orders can be completed.', command={'--time', '1', '--timeUnits', 'days', '--command', '[', 'orders', 'sort', ']'}}, ['orders-reevaluate']={ - desc='Invalidates manager orders once a month making it necessary to recheck conditions.', + desc='Invalidates work orders once a month forcing manager to recheck conditions.', command={'--time', '1', '--timeUnits', 'months', '--command', '[', 'orders', 'recheck', ']'}}, ['warn-starving']={ desc='Show a warning dialog when units are starving or dehydrated.', diff --git a/workorder-recheck.lua b/workorder-recheck.lua deleted file mode 100644 index 7115cdd09c..0000000000 --- a/workorder-recheck.lua +++ /dev/null @@ -1,103 +0,0 @@ --- Resets the selected work order to the `Checking` state - ---@ module = true - -local widgets = require('gui.widgets') -local overlay = require('plugins.overlay') - -local function set_current_inactive() - local scrConditions = df.global.game.main_interface.info.work_orders.conditions - if scrConditions.open then - local order = scrConditions.wq - order.status.active = false - else - qerror("Order conditions is not open") - end -end - -local function is_current_active() - local scrConditions = df.global.game.main_interface.info.work_orders.conditions - local order = scrConditions.wq - return order.status.active -end - --- ------------------- --- RecheckOverlay --- - -local focusString = 'dwarfmode/Info/WORK_ORDERS/Conditions' - -RecheckOverlay = defclass(RecheckOverlay, overlay.OverlayWidget) -RecheckOverlay.ATTRS{ - default_pos={x=6,y=8}, - default_enabled=true, - viewscreens=focusString, - -- width is the sum of lengths of `[` + `Ctrl+A` + `: ` + button.label + `]` - frame={w=1 + 6 + 2 + 16 + 1, h=3}, -} - -local function areTabsInTwoRows() - -- get the tile above the order status icon - local pen = dfhack.screen.readTile(7, 7, false) - -- in graphics mode, `0` when one row, something else when two (`67` aka 'C' from "Creatures") - -- in ASCII mode, `32` aka ' ' when one row, something else when two (`196` aka '-' from tab frame's top) - return (pen.ch ~= 0 and pen.ch ~= 32) -end - -function RecheckOverlay:updateTextButtonFrame() - local twoRows = areTabsInTwoRows() - if (self._twoRows == twoRows) then return false end - - self._twoRows = twoRows - local frame = twoRows - and {b=0, l=0, r=0, h=1} - or {t=0, l=0, r=0, h=1} - self.subviews.button.frame = frame - - return true -end - -function RecheckOverlay:init() - self:addviews{ - widgets.TextButton{ - view_id = 'button', - -- frame={t=0, l=0, r=0, h=1}, -- is set in `updateTextButtonFrame()` - label='request re-check', - key='CUSTOM_CTRL_A', - on_activate=set_current_inactive, - enabled=is_current_active, - }, - } - - self:updateTextButtonFrame() -end - -function RecheckOverlay:onRenderBody(dc) - if (self.frame_rect.y1 == 7) then - -- only apply this logic if the overlay is on the same row as - -- originally thought: just above the order status icon - - if self:updateTextButtonFrame() then - self:updateLayout() - end - end - - RecheckOverlay.super.onRenderBody(self, dc) -end - --- ------------------- - -OVERLAY_WIDGETS = { - recheck=RecheckOverlay, -} - -if dfhack_flags.module then - return -end - --- Check if on the correct screen and perform the action if so -if not dfhack.gui.matchFocusString(focusString) then - qerror('workorder-recheck must be run from the manager order conditions view') -end - -set_current_inactive() From 3fb36edc030f487a063243348bc306fe0a473134 Mon Sep 17 00:00:00 2001 From: Mikhail Panov Date: Fri, 22 Sep 2023 19:03:55 +0300 Subject: [PATCH 5/6] Removed workorder-recheck.rst. --- docs/workorder-recheck.rst | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 docs/workorder-recheck.rst diff --git a/docs/workorder-recheck.rst b/docs/workorder-recheck.rst deleted file mode 100644 index 9685823351..0000000000 --- a/docs/workorder-recheck.rst +++ /dev/null @@ -1,25 +0,0 @@ -workorder-recheck -================= - -.. dfhack-tool:: - :summary: Recheck start conditions for a manager workorder. - :tags: fort workorders - -Sets the status to ``Checking`` (from ``Active``) of the selected work order. -This makes the manager reevaluate its conditions. This is especially useful -for an order that had its conditions met when it was started, but the requisite -items have since disappeared and the workorder is now generating job cancellation -spam. - -Usage ------ - -:: - - workorder-recheck - -Overlay -------- - -The position of the "request re-check" text that appears when a workorder -conditions window is open is configurable via `gui/overlay`. From 85e61428786db2a010080967a76e0ceeac92f29c Mon Sep 17 00:00:00 2001 From: Myk Date: Wed, 27 Sep 2023 23:01:04 -0700 Subject: [PATCH 6/6] Update gui/control-panel.lua --- gui/control-panel.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/control-panel.lua b/gui/control-panel.lua index fb248e5cc4..2ee28bd60f 100644 --- a/gui/control-panel.lua +++ b/gui/control-panel.lua @@ -128,7 +128,7 @@ local REPEATS = { desc='Sort manager orders by repeat frequency so one-time orders can be completed.', command={'--time', '1', '--timeUnits', 'days', '--command', '[', 'orders', 'sort', ']'}}, ['orders-reevaluate']={ - desc='Invalidates work orders once a month forcing manager to recheck conditions.', + desc='Invalidates work orders once a month, allowing conditions to be rechecked.', command={'--time', '1', '--timeUnits', 'months', '--command', '[', 'orders', 'recheck', ']'}}, ['warn-starving']={ desc='Show a warning dialog when units are starving or dehydrated.',