Skip to content

Commit

Permalink
Merge branch 'develop' into adv-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 committed Jan 12, 2025
2 parents 1afd20d + 2a74278 commit 0a8841d
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 23 deletions.
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Template for new versions:

## New Features
- `stockpiles`: add simple import/export dialogs to stockpile overlay panel
- `orders`: add overlays to the manager orders screen that allow right clicks to cancel edit of quantities or condition details instead of exiting to the main screen

## Fixes
- `preserve-rooms`: don't erroneously release reservations for units that have returned from their missions but have not yet entered the fort map
Expand Down
36 changes: 23 additions & 13 deletions docs/plugins/orders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,32 @@ Examples
Import manager orders from the library that keep your fort stocked with
basic essentials.

Overlay
-------
Overlays
--------

The orders plugin provides several overlays managed by the `overlay` framework.
You can toggle them via the ``Overlays`` tab in `gui/control-panel` or
reposition the ones with onscreen widgets with `gui/overlay`.

Fort-wide work orders screen
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
orders.importexport
~~~~~~~~~~~~~~~~~~~

Orders plugin functionality is directly available via an `overlay` widget when
the fort-wide work orders screen is open. There are hotkeys assigned to export,
import, sort, clear, and recheck conditions. You can also click on the hotkey
hints as if they were buttons. Clearing will ask for confirmation before acting.
Adds a panel to the fort-wide work orders screen that allows access to `orders`
plugin functionality. There are hotkeys assigned to export, import, sort,
clear, and recheck conditions. You can also click on the hotkey hints as if
they were buttons. Clearing will ask for confirmation before acting.

When you open the conditions screen for a manager order, there is also a small
orders.recheck
~~~~~~~~~~~~~~

When you open the conditions screen for a manager order, there is a small
overlay that allows you to recheck conditions for just that order. This is
useful for when the conditions were true when the order started, but they have
become false and now you're just getting repeated cancellation spam as the
order cannot be fulfilled.

Workshop Workers tab
~~~~~~~~~~~~~~~~~~~~
orders.skillrestrictions and orders.laborrestrictions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For workshops that do *not* have a workshop master assigned, there is a slider
you can use to restrict the units that perform jobs at that workshop by their
Expand Down Expand Up @@ -106,8 +113,11 @@ Veteran players may remember these overlays as vanilla features in pre-v50 Dwarf
Fortress. This is actually still the case. The DFHack overlay simply provides a
UI for the vanilla feature hiding beneath the surface.

If you want to change where the overlay panels appear, you can move them with
`gui/overlay`.
orders.\*rightclick
~~~~~~~~~~~~~~~~~~~

These overlays are invisible interface improvements. They allow you to cancel
out of data entry with Escape or right mouse click without exiting the screen.

The orders library
------------------
Expand Down
7 changes: 6 additions & 1 deletion library/modules/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,13 @@ static void add_main_interface_focus_strings(const string &baseFocus, vector<str
break;
}
case df::enums::info_interface_mode_type::WORK_ORDERS:
if (game->main_interface.info.work_orders.conditions.open)
if (game->main_interface.info.work_orders.conditions.open) {
newFocusString += "/Conditions";
if (game->main_interface.info.work_orders.conditions.change_type != df::work_order_condition_change_type::NONE)
newFocusString += '/' + enum_item_key(game->main_interface.info.work_orders.conditions.change_type);
else
newFocusString += "/Default";
}
else if (game->main_interface.create_work_order.open)
newFocusString += "/Create";
else
Expand Down
2 changes: 1 addition & 1 deletion library/xml
Submodule xml updated 1 files
+8 −1 df.ui-menus.xml
85 changes: 78 additions & 7 deletions plugins/lua/orders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ local function do_recheck()
dfhack.run_command('orders', 'recheck')
end

local mi = df.global.game.main_interface

OrdersOverlay = defclass(OrdersOverlay, overlay.OverlayWidget)
OrdersOverlay.ATTRS{
desc='Adds import, export, and other functions to the manager orders screen.',
Expand Down Expand Up @@ -161,7 +163,7 @@ function OrdersOverlay:init()
end

function OrdersOverlay:onInput(keys)
if df.global.game.main_interface.job_details.open then return end
if mi.job_details.open then return end
if keys.CUSTOM_ALT_M then
self.minimized = not self.minimized
return true
Expand All @@ -172,14 +174,14 @@ function OrdersOverlay:onInput(keys)
end

function OrdersOverlay:render(dc)
if df.global.game.main_interface.job_details.open then return end
if mi.job_details.open then return end
OrdersOverlay.super.render(self, dc)
end

-- Resets the selected work order to the `Checking` state

local function set_current_inactive()
local scrConditions = df.global.game.main_interface.info.work_orders.conditions
local scrConditions = mi.info.work_orders.conditions
if scrConditions.open then
dfhack.run_command('orders', 'recheck', 'this')
else
Expand All @@ -188,7 +190,7 @@ local function set_current_inactive()
end

local function can_recheck()
local scrConditions = df.global.game.main_interface.info.work_orders.conditions
local scrConditions = mi.info.work_orders.conditions
local order = scrConditions.wq
return order.status.active and #order.item_conditions > 0
end
Expand All @@ -197,7 +199,7 @@ end
-- RecheckOverlay
--

local focusString = 'dwarfmode/Info/WORK_ORDERS/Conditions'
local focusString = 'dwarfmode/Info/WORK_ORDERS/Conditions/Default'

RecheckOverlay = defclass(RecheckOverlay, overlay.OverlayWidget)
RecheckOverlay.ATTRS{
Expand Down Expand Up @@ -413,7 +415,7 @@ end

function SkillRestrictionOverlay:onInput(keys)
if can_set_skill_level() and
not df.global.game.main_interface.view_sheets.building_entering_nickname
not mi.view_sheets.building_entering_nickname
then
return SkillRestrictionOverlay.super.onInput(self, keys)
end
Expand Down Expand Up @@ -635,19 +637,88 @@ end

function LaborRestrictionsOverlay:onInput(keys)
if can_set_labors() and
not df.global.game.main_interface.view_sheets.building_entering_nickname
not mi.view_sheets.building_entering_nickname
then
return LaborRestrictionsOverlay.super.onInput(self, keys)
end
end

---
--- ConditionsRightClickOverlay
---

ConditionsRightClickOverlay = defclass(ConditionsRightClickOverlay, overlay.OverlayWidget)
ConditionsRightClickOverlay.ATTRS{
desc='When adjusting condition details, makes right click cancel selection instead of exiting.',
default_enabled=true,
fullscreen=true,
viewscreens={
'dwarfmode/Info/WORK_ORDERS/Conditions/TYPE',
'dwarfmode/Info/WORK_ORDERS/Conditions/MATERIAL',
'dwarfmode/Info/WORK_ORDERS/Conditions/ADJECTIVE',
},
}

function ConditionsRightClickOverlay:onInput(keys)
if keys._MOUSE_R or keys.LEAVESCREEN then
mi.info.work_orders.conditions.change_type = df.work_order_condition_change_type.NONE
return true
end
end

---
--- ConditionsQuantityRightClickOverlay
---

ConditionsQuantityRightClickOverlay = defclass(ConditionsQuantityRightClickOverlay, overlay.OverlayWidget)
ConditionsQuantityRightClickOverlay.ATTRS{
desc='When adjusting condition quantities, makes right click cancel selection instead of exiting.',
default_enabled=true,
fullscreen=true,
viewscreens='dwarfmode/Info/WORK_ORDERS/Conditions/Default',
}

function ConditionsQuantityRightClickOverlay:onInput(keys)
if mi.info.work_orders.conditions.entering_logic_number and (keys._MOUSE_R or keys.LEAVESCREEN) then
mi.info.work_orders.conditions.entering_logic_number = false
return true
end
end

---
--- QuantityRightClickOverlay
---

QuantityRightClickOverlay = defclass(QuantityRightClickOverlay, overlay.OverlayWidget)
QuantityRightClickOverlay.ATTRS{
desc='When adjusting order quantity details, makes right click cancel selection instead of exiting.',
default_enabled=true,
fullscreen=true,
viewscreens='dwarfmode/Info/WORK_ORDERS/Default',
}

function QuantityRightClickOverlay:onInput(keys)
if keys._MOUSE_R or keys.LEAVESCREEN then
if mi.info.work_orders.entering_number then
mi.info.work_orders.entering_number = false
return true
elseif mi.info.work_orders.b_entering_number then
mi.info.work_orders.b_entering_number = false
return true
end
end
end

-- -------------------

OVERLAY_WIDGETS = {
recheck=RecheckOverlay,
importexport=OrdersOverlay,
skillrestrictions=SkillRestrictionOverlay,
laborrestrictions=LaborRestrictionsOverlay,
conditionsrightclick=ConditionsRightClickOverlay,
conditionsquantityrightclick=ConditionsQuantityRightClickOverlay,
quantityrightclick=QuantityRightClickOverlay,
}

return _ENV
2 changes: 1 addition & 1 deletion scripts
Submodule scripts updated 1 files
+1 −1 gui/rename.lua

0 comments on commit 0a8841d

Please sign in to comment.