only recheck orders that have conditions

develop
Myk Taylor 2023-10-08 09:47:40 -07:00
parent ab386a0ed2
commit a063c0cf41
No known key found for this signature in database
4 changed files with 24 additions and 18 deletions

@ -63,6 +63,7 @@ Template for new versions:
## Misc Improvements ## Misc Improvements
- `overlay`: allow ``overlay_onupdate_max_freq_seconds`` to be dynamically set to 0 for a burst of high-frequency updates - `overlay`: allow ``overlay_onupdate_max_freq_seconds`` to be dynamically set to 0 for a burst of high-frequency updates
- `orders`: ``recheck`` command now only resets orders that have conditions that can be rechecked
## Documentation ## Documentation

@ -18,12 +18,13 @@ Usage
``orders clear`` ``orders clear``
Deletes all manager orders in the current embark. Deletes all manager orders in the current embark.
``orders recheck [this]`` ``orders recheck [this]``
Sets the status to ``Checking`` (from ``Active``) for all work orders. if the Sets the status to ``Checking`` (from ``Active``) for all work orders that
"this" option is passed, only sets the status for the workorder whose condition have conditions that can be re-checked. If the "this" option is passed,
details page is open. This makes the manager reevaluate its conditions. only sets the status for the workorder whose condition details page is
This is especially useful for an order that had its conditions met when it open. This makes the manager reevaluate its conditions. This is especially
was started, but the requisite items have since disappeared and the workorder useful for an order that had its conditions met when it was started, but
is now generating job cancellation spam. the requisite items have since disappeared and the workorder is now
generating job cancellation spam.
``orders sort`` ``orders sort``
Sorts current manager orders by repeat frequency so repeating orders don't Sorts current manager orders by repeat frequency so repeating orders don't
prevent one-time orders from ever being completed. The sorting order is: prevent one-time orders from ever being completed. The sorting order is:

@ -71,7 +71,7 @@ OrdersOverlay.ATTRS{
default_pos={x=53,y=-6}, default_pos={x=53,y=-6},
default_enabled=true, default_enabled=true,
viewscreens='dwarfmode/Info/WORK_ORDERS/Default', viewscreens='dwarfmode/Info/WORK_ORDERS/Default',
frame={w=46, h=4}, frame={w=43, h=4},
} }
function OrdersOverlay:init() function OrdersOverlay:init()
@ -99,7 +99,7 @@ function OrdersOverlay:init()
}, },
widgets.HotkeyLabel{ widgets.HotkeyLabel{
frame={t=0, l=15}, frame={t=0, l=15},
label='recheck', label='recheck conditions',
key='CUSTOM_CTRL_K', key='CUSTOM_CTRL_K',
auto_width=true, auto_width=true,
on_activate=do_recheck, on_activate=do_recheck,
@ -112,7 +112,7 @@ function OrdersOverlay:init()
on_activate=do_sort, on_activate=do_sort,
}, },
widgets.HotkeyLabel{ widgets.HotkeyLabel{
frame={t=0, l=31}, frame={t=1, l=28},
label='clear', label='clear',
key='CUSTOM_CTRL_C', key='CUSTOM_CTRL_C',
auto_width=true, auto_width=true,
@ -179,10 +179,10 @@ local function set_current_inactive()
end end
end end
local function is_current_active() local function can_recheck()
local scrConditions = df.global.game.main_interface.info.work_orders.conditions local scrConditions = df.global.game.main_interface.info.work_orders.conditions
local order = scrConditions.wq local order = scrConditions.wq
return order.status.active return order.status.active and #order.item_conditions > 0
end end
-- ------------------- -- -------------------
@ -197,7 +197,7 @@ RecheckOverlay.ATTRS{
default_enabled=true, default_enabled=true,
viewscreens=focusString, viewscreens=focusString,
-- width is the sum of lengths of `[` + `Ctrl+A` + `: ` + button.label + `]` -- width is the sum of lengths of `[` + `Ctrl+A` + `: ` + button.label + `]`
frame={w=1 + 6 + 2 + 16 + 1, h=3}, frame={w=1 + 6 + 2 + 19 + 1, h=3},
} }
local function areTabsInTwoRows() local function areTabsInTwoRows()
@ -226,10 +226,10 @@ function RecheckOverlay:init()
widgets.TextButton{ widgets.TextButton{
view_id = 'button', view_id = 'button',
-- frame={t=0, l=0, r=0, h=1}, -- is set in `updateTextButtonFrame()` -- frame={t=0, l=0, r=0, h=1}, -- is set in `updateTextButtonFrame()`
label='request re-check', label='re-check conditions',
key='CUSTOM_CTRL_A', key='CUSTOM_CTRL_A',
on_activate=set_current_inactive, on_activate=set_current_inactive,
enabled=is_current_active, enabled=can_recheck,
}, },
} }

@ -1036,11 +1036,15 @@ static command_result orders_sort_command(color_ostream & out)
static command_result orders_recheck_command(color_ostream & out) static command_result orders_recheck_command(color_ostream & out)
{ {
for (auto it : world->manager_orders) size_t count = 0;
{ for (auto it : world->manager_orders) {
it->status.bits.active = false; if (it->item_conditions.size() && it->status.bits.active) {
it->status.bits.validated = false; ++count;
it->status.bits.active = false;
it->status.bits.validated = false;
}
} }
out << "Re-checking conditions for " << count << " manager orders." << std::endl;
return CR_OK; return CR_OK;
} }