From 63772fd808107c37627ae5d5946a25baa7173d64 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 27 Mar 2023 03:51:45 -0700 Subject: [PATCH 1/7] ensure rclicks don't bleed through for dialogs --- library/lua/gui/dialogs.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/library/lua/gui/dialogs.lua b/library/lua/gui/dialogs.lua index 3b2470114..1b7858416 100644 --- a/library/lua/gui/dialogs.lua +++ b/library/lua/gui/dialogs.lua @@ -4,9 +4,6 @@ local _ENV = mkmodule('gui.dialogs') local gui = require('gui') local widgets = require('gui.widgets') -local utils = require('utils') - -local dscreen = dfhack.screen MessageBox = defclass(MessageBox, gui.FramedScreen) @@ -66,6 +63,7 @@ function MessageBox:onInput(keys) elseif (keys.LEAVESCREEN or keys._MOUSE_R_DOWN) and self.on_cancel then self.on_cancel() end + gui.markMouseClicksHandled(keys) return true end return self:inputToSubviews(keys) @@ -135,6 +133,7 @@ function InputBox:onInput(keys) if self.on_cancel then self.on_cancel() end + gui.markMouseClicksHandled(keys) return true end return self:inputToSubviews(keys) @@ -218,9 +217,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):string('Shift-Click', COLOR_LIGHTGREEN):string(': '..self.select2_hint, COLOR_GREY) + end end function ListBox:getWantedFrameSize() @@ -236,6 +235,7 @@ function ListBox:onInput(keys) if self.on_cancel then self.on_cancel() end + gui.markMouseClicksHandled(keys) return true end return self:inputToSubviews(keys) From 0ed311c108ec68bcc0ddcd9063f08417130479b1 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 27 Mar 2023 03:52:12 -0700 Subject: [PATCH 2/7] allow exported orders files to be deleted from the import dialog --- plugins/lua/orders.lua | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/plugins/lua/orders.lua b/plugins/lua/orders.lua index 6f5bc677a..50197fce4 100644 --- a/plugins/lua/orders.lua +++ b/plugins/lua/orders.lua @@ -19,15 +19,37 @@ local function do_clear() function() dfhack.run_command('orders', 'clear') end) end +local function get_import_choices() + return dfhack.run_command_silent('orders', 'list'):split('\n') +end + local function do_import() - local output = dfhack.run_command_silent('orders', 'list') - dialogs.ListBox{ - frame_title='Import Manager Orders', + local dlg + local function get_dlg() return dlg end + dlg = dialogs.ListBox{ + frame_title='Import/Delete Manager Orders', with_filter=true, - choices=output:split('\n'), - on_select=function(idx, choice) + choices=get_import_choices(), + on_select=function(_, choice) dfhack.run_command('orders', 'import', choice.text) end, + dismiss_on_select2=false, + on_select2=function(_, choice) + if choice.text:startswith('library/') then return end + local fname = 'dfhack-config/orders/'..choice.text..'.json' + if not dfhack.filesystem.isfile(fname) then return end + dialogs.showYesNoPrompt('Delete orders file?', + 'Are you sure you want to delete "' .. fname .. '"?', nil, + function() + print('deleting ' .. fname) + os.remove(fname) + local list = get_dlg().subviews.list + local filter = list:getFilter() + list:setChoices(get_import_choices(), list:getSelected()) + list:setFilter(filter) + end) + end, + select2_hint='Delete file', }:show() end From d5c8237c913b655d9dc3060aa98810740c129ffa Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 27 Mar 2023 03:53:10 -0700 Subject: [PATCH 3/7] update changelog --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 65194dcfa..d55ab6585 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -59,6 +59,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - `stockpiles`: now includes a library of useful stockpile configs (see docs for details) - `automelt`: now allows metal chests to be melted (workaround for DF bug 2493 is no longer needed) - `orders`: add minimize button to overlay panel so you can get it out of the way to read long statue descriptions when choosing a subject in the details screen +- `orders`: add option to delete exported files from the import dialog - `enable`: can now interpret aliases defined with the `alias` command - scripts in installed mods are now automatically added to the DFHack script path. DFHack recognizes two directories in a mod's folder: ``scripts_modinstalled/`` and ``scripts_modactive/``. ``scripts_modinstalled/`` folders will always be added the script path, regardless of whether the mod is active in a world. ``scripts_modactive/`` folders will only be added to the script path when the mod is active in the current loaded world. From b515b337ea55ed06c5223f81f861a77920014d5b Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 27 Mar 2023 08:38:18 -0700 Subject: [PATCH 4/7] silence noisy buildingplan warning about itemless buildings not having items --- plugins/buildingplan/defaultitemfilters.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/buildingplan/defaultitemfilters.cpp b/plugins/buildingplan/defaultitemfilters.cpp index fc7dd9f56..ac0a4699e 100644 --- a/plugins/buildingplan/defaultitemfilters.cpp +++ b/plugins/buildingplan/defaultitemfilters.cpp @@ -60,6 +60,8 @@ DefaultItemFilters::DefaultItemFilters(color_ostream &out, PersistentDataItem &f auto &serialized = filter_config.val(); DEBUG(status,out).print("deserializing default item filters for key %d,%d,%d: %s\n", std::get<0>(key), std::get<1>(key), std::get<2>(key), serialized.c_str()); + if (!jitems.size()) + return; std::vector elems; split_string(&elems, serialized, "|"); std::vector filters = deserialize_item_filters(out, elems[0]); From df51835b1c5d076f3e7440b37e307100bc8b25be Mon Sep 17 00:00:00 2001 From: Tachytaenius Date: Mon, 27 Mar 2023 22:05:06 +0100 Subject: [PATCH 5/7] Amend main module code in modding guide --- docs/guides/modding-guide.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/guides/modding-guide.rst b/docs/guides/modding-guide.rst index 5cabf0856..b386b48c3 100644 --- a/docs/guides/modding-guide.rst +++ b/docs/guides/modding-guide.rst @@ -457,6 +457,8 @@ Ok, you're all set up! Now, let's take a look at an example enabled = enabled or false function isEnabled() + -- this function is for the enabled API, the script won't show up on the + -- control panel without it return enabled end @@ -473,6 +475,10 @@ Ok, you're all set up! Now, let's take a look at an example dfhack.run_command('enable', 'example-mod') end + if dfhack_flags.module then + return + end + if not dfhack_flags.enable then print(dfhack.script_help()) print() From 02b52fcb3decced37bad3dfd6226f35e7ddf6457 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 27 Mar 2023 16:11:21 -0700 Subject: [PATCH 6/7] confirm for removing burrows via the repaint menu --- docs/changelog.txt | 1 + docs/plugins/confirm.rst | 5 +++-- plugins/lua/confirm.lua | 7 +++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index d55ab6585..62aa4a037 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -52,6 +52,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Misc Improvements - `buildingplan`: filters and global settings are now ignored when manually choosing items for a building +- `confirm`: adds confirmation for removing burrows via the repaint menu - `stockpiles`: support applying stockpile configurations with fully enabled categories to stockpiles in worlds other than the one where the configuration was exported from - `stockpiles`: support partial application of a saved config based on dynamic filtering - `stockpiles`: additive and subtractive modes when applying a second stockpile configuration on top of a first diff --git a/docs/plugins/confirm.rst b/docs/plugins/confirm.rst index f0a34b909..1e6270187 100644 --- a/docs/plugins/confirm.rst +++ b/docs/plugins/confirm.rst @@ -5,8 +5,9 @@ confirm :summary: Adds confirmation dialogs for destructive actions. :tags: fort interface -Now you can get the chance to avoid accidentally disbanding a squad or deleting a -hauling route in case you hit the key accidentally. +In the base game, it is frightenly easy to destroy hours of work with a single +misclick. Now you can avoid the consequences of accidentally disbanding a squad +(for example), or deleting a hauling route. Usage ----- diff --git a/plugins/lua/confirm.lua b/plugins/lua/confirm.lua index 13964645b..1ddf190b4 100644 --- a/plugins/lua/confirm.lua +++ b/plugins/lua/confirm.lua @@ -12,10 +12,11 @@ setmetatable(keys, { -- Mouse keys will be sent as a string instead of interface_key local MOUSE_LEFT = "MOUSE_LEFT" local MOUSE_RIGHT = "MOUSE_RIGHT" + --[[ The screen where a confirmation has been triggered Note that this is *not* necessarily the topmost viewscreen, so do not use gui.getCurViewscreen() or related functions. ]] -screen = nil +--screen = nil function if_nil(obj, default) if obj == nil then @@ -118,7 +119,9 @@ zone_remove.message = "Are you sure you want to remove this zone?" burrow_remove = defconf('burrow-remove') function burrow_remove.intercept_key(key) - return key == MOUSE_LEFT and df.global.game.main_interface.current_hover == 171 + return key == MOUSE_LEFT and + (df.global.game.main_interface.current_hover == 171 or + df.global.game.main_interface.current_hover == 168) end burrow_remove.title = "Remove burrow" burrow_remove.message = "Are you sure you want to remove this burrow?" From db45d20c237904d63a13a752bdce7c917374d3c1 Mon Sep 17 00:00:00 2001 From: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com> Date: Tue, 28 Mar 2023 07:14:31 +0000 Subject: [PATCH 7/7] Auto-update submodules scripts: master --- scripts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts b/scripts index bb3dfc0d3..27089b81b 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit bb3dfc0d3e2bdebc4ba6fd814371662457b18917 +Subproject commit 27089b81be6f9de9486118a97a15be4dde09b1b3