diff --git a/docs/changelog.txt b/docs/changelog.txt index 217abe32ea..718aba5f02 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -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 diff --git a/docs/plugins/orders.rst b/docs/plugins/orders.rst index b37e3d85f0..2e70b29a7a 100644 --- a/docs/plugins/orders.rst +++ b/docs/plugins/orders.rst @@ -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 @@ -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 ------------------ diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index aa15076a4b..3e9dd0dda9 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -446,8 +446,13 @@ static void add_main_interface_focus_strings(const string &baseFocus, vectormain_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 diff --git a/library/xml b/library/xml index 2abeeb689f..1db828e1f0 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 2abeeb689fa168bde8e28e183b72caaf6c10e420 +Subproject commit 1db828e1f0d20ad788ee883dbb2b9ae7c859f240 diff --git a/plugins/lua/orders.lua b/plugins/lua/orders.lua index 6d23988fea..2774bd80ee 100644 --- a/plugins/lua/orders.lua +++ b/plugins/lua/orders.lua @@ -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.', @@ -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 @@ -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 @@ -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 @@ -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{ @@ -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 @@ -635,12 +637,78 @@ 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 = { @@ -648,6 +716,9 @@ OVERLAY_WIDGETS = { importexport=OrdersOverlay, skillrestrictions=SkillRestrictionOverlay, laborrestrictions=LaborRestrictionsOverlay, + conditionsrightclick=ConditionsRightClickOverlay, + conditionsquantityrightclick=ConditionsQuantityRightClickOverlay, + quantityrightclick=QuantityRightClickOverlay, } return _ENV diff --git a/scripts b/scripts index fc358acf8c..bdb136707d 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit fc358acf8cc753a5848a1740f0969973a4979e31 +Subproject commit bdb136707d0621f2e0f10af38962be43f7791e4a