From 76822ac7b783f0e4be0fb60b3fe29d404d6472ea Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 22 Jan 2023 00:59:27 -0800 Subject: [PATCH 1/7] remove orphan fortplan.lua file --- plugins/lua/fortplan.lua | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 plugins/lua/fortplan.lua diff --git a/plugins/lua/fortplan.lua b/plugins/lua/fortplan.lua deleted file mode 100644 index 71e69c69d..000000000 --- a/plugins/lua/fortplan.lua +++ /dev/null @@ -1,13 +0,0 @@ -local _ENV = mkmodule('plugins.fortplan') - -require('dfhack.buildings') - -function construct_building_from_params(building_type, x, y, z) - local pos = xyz2pos(x, y, z) - local bld, err = - dfhack.buildings.constructBuilding{type=building_type, pos=pos} - if err then error(err) end - return bld -end - -return _ENV From b84bce719d5dfa01e93b2eb12b8526a4d5a751d5 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 22 Jan 2023 01:07:30 -0800 Subject: [PATCH 2/7] remove unused always_enabled attribute for overlays it was made for gui/pathable, but that became a ZScreen this option made me uncomfortable for overlays. it didn't seem like the right user experience --- docs/dev/overlay-dev-guide.rst | 4 ---- plugins/lua/overlay.lua | 4 +--- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/docs/dev/overlay-dev-guide.rst b/docs/dev/overlay-dev-guide.rst index bce623180..50998530a 100644 --- a/docs/dev/overlay-dev-guide.rst +++ b/docs/dev/overlay-dev-guide.rst @@ -125,10 +125,6 @@ The ``overlay.OverlayWidget`` superclass defines the following class attributes: not annoy the player. Set to 0 to be called at the maximum rate. Be aware that running more often than you really need to will impact game FPS, especially if your widget can run while the game is unpaused. -- ``always_enabled`` (default: ``false``) - Set this to ``true`` if you don't want to let the user disable the widget. - This is useful for widgets that are controlled purely through their - triggers. See `gui/pathable` for an example. Registering a widget with the overlay framework *********************************************** diff --git a/plugins/lua/overlay.lua b/plugins/lua/overlay.lua index cf599fd08..b90c1c651 100644 --- a/plugins/lua/overlay.lua +++ b/plugins/lua/overlay.lua @@ -184,7 +184,6 @@ end local function do_disable(args, quiet) local disable_fn = function(name, db_entry) - if db_entry.widget.always_enabled then return end overlay_config[name].enabled = false if db_entry.widget.hotspot then active_hotspot_widgets[name] = nil @@ -252,7 +251,7 @@ local function load_widget(name, widget_class) local config = overlay_config[name] config.pos = sanitize_pos(config.pos or widget.default_pos) widget.frame = make_frame(config.pos, widget.frame) - if config.enabled or widget.always_enabled then + if config.enabled then do_enable(name, true, true) else config.enabled = false @@ -492,7 +491,6 @@ OverlayWidget.ATTRS{ hotspot=false, -- whether to call overlay_onupdate on all screens viewscreens={}, -- override with associated viewscreen or list of viewscrens overlay_onupdate_max_freq_seconds=5, -- throttle calls to overlay_onupdate - always_enabled=false, -- for overlays that should never be disabled } function OverlayWidget:init() From f0d44342d891bc42e9cd45d66d7732ea1a50d535 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 22 Jan 2023 03:08:36 -0800 Subject: [PATCH 3/7] first attempt at a manager orders overlay --- plugins/CMakeLists.txt | 2 +- plugins/lua/orders.lua | 100 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 plugins/lua/orders.lua diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 3d36b95fc..a05ae6a83 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -134,7 +134,7 @@ dfhack_plugin(misery misery.cpp) #dfhack_plugin(mode mode.cpp) #dfhack_plugin(mousequery mousequery.cpp) dfhack_plugin(nestboxes nestboxes.cpp) -dfhack_plugin(orders orders.cpp LINK_LIBRARIES jsoncpp_static) +dfhack_plugin(orders orders.cpp LINK_LIBRARIES jsoncpp_static lua) dfhack_plugin(overlay overlay.cpp LINK_LIBRARIES lua) dfhack_plugin(pathable pathable.cpp LINK_LIBRARIES lua) #dfhack_plugin(petcapRemover petcapRemover.cpp) diff --git a/plugins/lua/orders.lua b/plugins/lua/orders.lua new file mode 100644 index 000000000..aecd940d6 --- /dev/null +++ b/plugins/lua/orders.lua @@ -0,0 +1,100 @@ +local _ENV = mkmodule('plugins.orders') + +local dialogs = require('gui.dialogs') +local gui = require('gui') +local overlay = require('plugins.overlay') +local widgets = require('gui.widgets') + +-- +-- OrdersOverlay +-- + +local function is_orders_panel_visible() + local info = df.global.game.main_interface.info + return info.open and info.current_mode == df.info_interface_mode_type.WORK_ORDERS +end + +local function do_sort() + dfhack.run_command('orders', 'sort') +end + +local function do_clear() + dialogs.showYesNoPrompt('Clear manager orders?', + 'Are you sure you want to clear the manager orders?', nil, + function() dfhack.run_command('orders', 'clear') end) +end + +local function do_import() + local output = dfhack.run_command_silent('orders', 'list') + dialogs.ListBox{ + frame_title='Import Manager Orders', + with_filter=true, + choices=output:split('\n'), + on_select=function(idx, choice) + dfhack.run_command('orders', 'import', choice.text) + end, + }:show() +end + +local function do_export() + dialogs.InputBox{ + frame_title='Export Manager Orders', + on_input=function(text) + dfhack.run_command('orders', 'export', text) + end + }:show() +end + +OrdersOverlay = defclass(OrdersOverlay, overlay.OverlayWidget) +OrdersOverlay.ATTRS{ + default_pos={x=61,y=-6}, + viewscreens='dwarfmode', + frame={w=30, h=4}, + frame_style=gui.GREY_LINE_FRAME, + frame_background=gui.CLEAR_PEN, +} + +function OrdersOverlay:init() + self:addviews{ + widgets.HotkeyLabel{ + frame={t=0, l=0}, + label='import', + key='CUSTOM_CTRL_I', + on_activate=do_import, + }, + widgets.HotkeyLabel{ + frame={t=1, l=0}, + label='export', + key='CUSTOM_CTRL_E', + on_activate=do_export, + }, + widgets.HotkeyLabel{ + frame={t=0, l=15}, + label='sort', + key='CUSTOM_CTRL_O', + on_activate=do_sort, + }, + widgets.HotkeyLabel{ + frame={t=1, l=15}, + label='clear', + key='CUSTOM_CTRL_C', + on_activate=do_clear, + }, + } +end + +function OrdersOverlay:render(dc) + if not is_orders_panel_visible() then return false end + OrdersOverlay.super.render(self, dc) +end + +function OrdersOverlay:onInput(keys) + if not is_orders_panel_visible() then return false end + OrdersOverlay.super.onInput(self, keys) +end + +OVERLAY_WIDGETS = { + overlay=OrdersOverlay, +} + +return _ENV From f862e4a6b713a78fb7fb03b77f6316ab702f4c5a Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 22 Jan 2023 03:09:07 -0800 Subject: [PATCH 4/7] comment out SEC_SELECT in dialogs --- library/lua/gui/dialogs.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/lua/gui/dialogs.lua b/library/lua/gui/dialogs.lua index e7228db1e..0b923e7c0 100644 --- a/library/lua/gui/dialogs.lua +++ b/library/lua/gui/dialogs.lua @@ -218,9 +218,9 @@ end function ListBox:onRenderFrame(dc,rect) ListBox.super.onRenderFrame(self,dc,rect) - if self.select2_hint then - dc:seek(rect.x1+2,rect.y2):key('SEC_SELECT'):string(': '..self.select2_hint,COLOR_GREY) - end + --if self.select2_hint then + -- dc:seek(rect.x1+2,rect.y2):key('SEC_SELECT'):string(': '..self.select2_hint,COLOR_GREY) + --end end function ListBox:getWantedFrameSize() From 740abba621f26f097b345ed7693f1fc4ccc4a524 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 22 Jan 2023 08:40:16 -0800 Subject: [PATCH 5/7] update comments in quickfort config file --- data/dfhack-config/quickfort/quickfort.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/dfhack-config/quickfort/quickfort.txt b/data/dfhack-config/quickfort/quickfort.txt index e3f5aeaec..92af2909e 100644 --- a/data/dfhack-config/quickfort/quickfort.txt +++ b/data/dfhack-config/quickfort/quickfort.txt @@ -4,8 +4,8 @@ # temporarily overridden in the active session with the `quickfort set` command. # # If you have edited this file but want to revert to "factory defaults", delete -# this file and a fresh one will be copied from -# dfhack-config/default/quickfort/quickfort.txt the next time you start DFHack. +# this file and a default one will be regenerated for you the next time you +# start DFHack. # Directory tree to search for blueprints. Can be set to an absolute or relative # path. If set to a relative path, resolves to a directory under the DF folder. @@ -30,8 +30,8 @@ query_unsafe=false # Set to the maximum number of resources you want assigned to stockpiles of the # relevant types. Set to -1 for DF defaults (number of stockpile tiles for # stockpiles that take barrels and bins, 1 wheelbarrow for stone stockpiles). -# The default here for wheelbarrows is 0 since using wheelbarrows normally -# *decreases* the efficiency of your fort. +# The default here for wheelbarrows is 0 since restricting stockpiles to a +# single wheelbarrow can drastically *decrease* the efficiency of your fort. stockpiles_max_barrels=-1 stockpiles_max_bins=-1 stockpiles_max_wheelbarrows=0 From b4c49f36e11fa98f75ef6cf3afc55bf0d6975eef Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 22 Jan 2023 15:39:05 -0800 Subject: [PATCH 6/7] document orders overlay --- docs/plugins/orders.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/plugins/orders.rst b/docs/plugins/orders.rst index 8beb246e4..5dfe23758 100644 --- a/docs/plugins/orders.rst +++ b/docs/plugins/orders.rst @@ -40,6 +40,17 @@ Examples Import manager orders from the library that keep your fort stocked with basic essentials. +Overlay +------- + +Orders plugin functionality is directly available when the manager orders screen +is open via an `overlay` widget. There are hotkeys assigned to export, import, +sort, and clear. You can also click on the hotkey hints as if they were buttons. +Clearing will ask for confirmation before acting. + +If you want to change where the hotkey hints appear, you can move them via +`gui/overlay`. + The orders library ------------------ From 0c5514ff2d0aa2079468965b19a2b6e968eaffbd Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 22 Jan 2023 15:39:12 -0800 Subject: [PATCH 7/7] update changelog --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 94b7d61c9..4a484f692 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -38,6 +38,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Fixes ## Misc Improvements +- `orders`: orders plugin functionality is now offered via an overlay widget when the manager orders screen is open ## Documentation