From 6b34c3bc3a5061a7922f06895b6466962893f80c Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Wed, 19 Mar 2025 12:08:24 -0500 Subject: [PATCH 01/18] Create toolbar overlay for mass-remove --- mass-remove.lua | 115 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 mass-remove.lua diff --git a/mass-remove.lua b/mass-remove.lua new file mode 100644 index 000000000..5150a3673 --- /dev/null +++ b/mass-remove.lua @@ -0,0 +1,115 @@ +--@ module = true + +local gui = require('gui') +local overlay = require('plugins.overlay') +local widgets = require('gui.widgets') + +local toolbar_textures = (dfhack.textures.loadTileset('hack/data/art/mass_remove_toolbar.png', 8,12)) + +local BASELINE_OFFSET = 42 + +local function get_l_offset(parent_rect) + local w = parent_rect.width + if w <= 177 then + return BASELINE_OFFSET + w - 114 + end + return BASELINE_OFFSET + (w+1)//2 - 26 +end + +function launch_mass_remove() + dfhack.run_command('gui/mass-remove') +end + + +-- -------------------------------- +-- MassRemoveToolbarOverlay +-- + +MassRemoveToolbarOverlay = defclass(MassRemoveToolbarOverlay, overlay.OverlayWidget) +MassRemoveToolbarOverlay.ATTRS{ + desc='Adds widgets to the erase interface to open the mass removal tool', + default_pos={x=BASELINE_OFFSET, y=-4}, + default_enabled=true, + viewscreens={ + 'dwarfmode/Designate/ERASE' + }, + frame={w=26, h=11}, +} + +function MassRemoveToolbarOverlay:init() + local button_chars = { + {218, 196, 196, 191}, + {179, 'M', 'R', 179}, + {192, 196, 196, 217}, + } + + self:addviews{ + widgets.Panel{ + frame={t=0, r=0, w=26, h=7}, + frame_style=gui.FRAME_PANEL, + frame_background=gui.CLEAR_PEN, + frame_inset={l=1, r=1}, + visible=function() return not not self.subviews.icon:getMousePos() end, + subviews={ + widgets.Label{ + text={ + 'Open mass removal\ninterface.\n', + NEWLINE, + {text='Hotkey: ', pen=COLOR_GRAY}, {key='CUSTOM_CTRL_M'}, + }, + }, + }, + }, + widgets.Panel{ + view_id='icon', + frame={b=0, r=22, w=4, h=3}, + subviews={ + widgets.Label{ + text=widgets.makeButtonLabelText{ + chars=button_chars, + pens=COLOR_GRAY, + tileset=toolbar_textures, + tileset_offset=1, + tileset_stride=8, + }, + on_click=launch_mass_remove, + visible=function () return not self.subviews.icon:getMousePos() end, + }, + widgets.Label{ + text=widgets.makeButtonLabelText{ + chars=button_chars, + pens={ + {COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE}, + {COLOR_WHITE, COLOR_GRAY, COLOR_GRAY, COLOR_WHITE}, + {COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE}, + }, + tileset=toolbar_textures, + tileset_offset=5, + tileset_stride=8, + }, + on_click=launch_mass_remove, + visible=function() return not not self.subviews.icon:getMousePos() end, + }, + }, + }, + } +end + +function MassRemoveToolbarOverlay:preUpdateLayout(parent_rect) + self.frame.w = get_l_offset(parent_rect) - BASELINE_OFFSET + 18 + print(self.frame.w) +end + +function MassRemoveToolbarOverlay:onInput(keys) + if keys.CUSTOM_CTRL_M then + launch_mass_remove() + return true + end + return MassRemoveToolbarOverlay.super.onInput(self, keys) +end + +OVERLAY_WIDGETS = {massremovetoolbar=MassRemoveToolbarOverlay} + +if dfhack_flags.module then + return +end \ No newline at end of file From c5bfc79d9fc93354786d02e2be672689d4612efd Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Wed, 19 Mar 2025 12:12:21 -0500 Subject: [PATCH 02/18] fix EOF --- mass-remove.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mass-remove.lua b/mass-remove.lua index 5150a3673..62ffd9595 100644 --- a/mass-remove.lua +++ b/mass-remove.lua @@ -112,4 +112,4 @@ OVERLAY_WIDGETS = {massremovetoolbar=MassRemoveToolbarOverlay} if dfhack_flags.module then return -end \ No newline at end of file +end From a21dc0b61475c4d6589d172d638df653f6227403 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Wed, 19 Mar 2025 12:31:03 -0500 Subject: [PATCH 03/18] remove dbug code that snuck in --- mass-remove.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/mass-remove.lua b/mass-remove.lua index 62ffd9595..eb5b0b8ce 100644 --- a/mass-remove.lua +++ b/mass-remove.lua @@ -97,7 +97,6 @@ end function MassRemoveToolbarOverlay:preUpdateLayout(parent_rect) self.frame.w = get_l_offset(parent_rect) - BASELINE_OFFSET + 18 - print(self.frame.w) end function MassRemoveToolbarOverlay:onInput(keys) From 7bf28144c0f5ebecec04925d4c8ea59e132b6a98 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Wed, 19 Mar 2025 14:27:09 -0500 Subject: [PATCH 04/18] Fix icon to not move when window resizes --- mass-remove.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mass-remove.lua b/mass-remove.lua index eb5b0b8ce..f33f3361f 100644 --- a/mass-remove.lua +++ b/mass-remove.lua @@ -10,10 +10,7 @@ local BASELINE_OFFSET = 42 local function get_l_offset(parent_rect) local w = parent_rect.width - if w <= 177 then - return BASELINE_OFFSET + w - 114 - end - return BASELINE_OFFSET + (w+1)//2 - 26 + return BASELINE_OFFSET + (w+1)//2 - 34 end function launch_mass_remove() From c7341ddacc99262d6f9887a37468f5bd9e830059 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Wed, 19 Mar 2025 14:31:04 -0500 Subject: [PATCH 05/18] change the eraser menu hotkey to use just `m` --- mass-remove.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mass-remove.lua b/mass-remove.lua index f33f3361f..a7b9879e8 100644 --- a/mass-remove.lua +++ b/mass-remove.lua @@ -52,7 +52,7 @@ function MassRemoveToolbarOverlay:init() text={ 'Open mass removal\ninterface.\n', NEWLINE, - {text='Hotkey: ', pen=COLOR_GRAY}, {key='CUSTOM_CTRL_M'}, + {text='Hotkey: ', pen=COLOR_GRAY}, {key='CUSTOM_M'}, }, }, }, @@ -97,7 +97,7 @@ function MassRemoveToolbarOverlay:preUpdateLayout(parent_rect) end function MassRemoveToolbarOverlay:onInput(keys) - if keys.CUSTOM_CTRL_M then + if keys.CUSTOM_M then launch_mass_remove() return true end From aafb0d1fc4fd25e718de6df6d3666deaa38ae0ce Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Wed, 19 Mar 2025 14:31:34 -0500 Subject: [PATCH 06/18] close the eraser menu when we open mass remove so the ui is less cluttered --- mass-remove.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mass-remove.lua b/mass-remove.lua index a7b9879e8..0050ddab0 100644 --- a/mass-remove.lua +++ b/mass-remove.lua @@ -14,6 +14,8 @@ local function get_l_offset(parent_rect) end function launch_mass_remove() + local vs = dfhack.gui.getDFViewscreen(true) + gui.simulateInput(vs,'LEAVESCREEN') dfhack.run_command('gui/mass-remove') end From 48d896bb93231611b3b8fd23f36d4737694ffea3 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Wed, 19 Mar 2025 23:09:16 -0500 Subject: [PATCH 07/18] Clean up clean up the looks of the toolt --- mass-remove.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mass-remove.lua b/mass-remove.lua index 0050ddab0..1c5188749 100644 --- a/mass-remove.lua +++ b/mass-remove.lua @@ -44,7 +44,7 @@ function MassRemoveToolbarOverlay:init() self:addviews{ widgets.Panel{ - frame={t=0, r=0, w=26, h=7}, + frame={t=0, r=0, w=26, h=6}, frame_style=gui.FRAME_PANEL, frame_background=gui.CLEAR_PEN, frame_inset={l=1, r=1}, @@ -52,7 +52,7 @@ function MassRemoveToolbarOverlay:init() subviews={ widgets.Label{ text={ - 'Open mass removal\ninterface.\n', + 'Open mass removal\ninterface.', NEWLINE, NEWLINE, {text='Hotkey: ', pen=COLOR_GRAY}, {key='CUSTOM_M'}, }, From 419cedff525488bcc9aa331940b04660b7777791 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Sat, 22 Mar 2025 18:48:22 -0500 Subject: [PATCH 08/18] Create mass-remove.rst --- docs/mass-remove.rst | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 docs/mass-remove.rst diff --git a/docs/mass-remove.rst b/docs/mass-remove.rst new file mode 100644 index 000000000..6f17685ed --- /dev/null +++ b/docs/mass-remove.rst @@ -0,0 +1,6 @@ +mass-remove +=========== + +The mass-remove.massremovetoolbar overlay adds a button to the toolbar at the bottom of the +screen when eraser mode is active. It allows you to conveniently open the ``gui/mass-remove`` +interface. From f1b53c39cf9e384bf27428712bc9da822f7a273e Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Sat, 22 Mar 2025 18:56:09 -0500 Subject: [PATCH 09/18] Fix docs --- docs/gui/mass-remove.rst | 14 ++++++++++++++ docs/mass-remove.rst | 6 ------ 2 files changed, 14 insertions(+), 6 deletions(-) delete mode 100644 docs/mass-remove.rst diff --git a/docs/gui/mass-remove.rst b/docs/gui/mass-remove.rst index 6a3becb8f..66e3b759f 100644 --- a/docs/gui/mass-remove.rst +++ b/docs/gui/mass-remove.rst @@ -19,3 +19,17 @@ Usage :: gui/mass-remove + + +Overlay +------- + +This tool also provides one overlay that is managed by the `overlay` +framework. + +massremovetoolbar +~~~~~~~~~~~~~~~~~ + +The mass-remove.massremovetoolbar overlay adds a button to the toolbar at the bottom of the +screen when eraser mode is active. It allows you to conveniently open the ``gui/mass-remove`` +interface. diff --git a/docs/mass-remove.rst b/docs/mass-remove.rst deleted file mode 100644 index 6f17685ed..000000000 --- a/docs/mass-remove.rst +++ /dev/null @@ -1,6 +0,0 @@ -mass-remove -=========== - -The mass-remove.massremovetoolbar overlay adds a button to the toolbar at the bottom of the -screen when eraser mode is active. It allows you to conveniently open the ``gui/mass-remove`` -interface. From b61d4cb881d814225e49cf857e91276eae9143ae Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Sat, 22 Mar 2025 19:04:12 -0500 Subject: [PATCH 10/18] merge into the real mass remove --- gui/mass-remove.lua | 108 ++++++++++++++++++++++++++++++++++++++++++ mass-remove.lua | 113 -------------------------------------------- 2 files changed, 108 insertions(+), 113 deletions(-) delete mode 100644 mass-remove.lua diff --git a/gui/mass-remove.lua b/gui/mass-remove.lua index f138c50d8..a141874f3 100644 --- a/gui/mass-remove.lua +++ b/gui/mass-remove.lua @@ -1,13 +1,31 @@ -- building/construction mass removal/suspension tool +--@ module = true + +local toolbar_textures = (dfhack.textures.loadTileset('hack/data/art/mass_remove_toolbar.png', 8,12)) + +local BASELINE_OFFSET = 42 + local gui = require('gui') local guidm = require('gui.dwarfmode') local utils = require('utils') local widgets = require('gui.widgets') +local overlay = require('plugins.overlay') local function noop() end +local function get_l_offset(parent_rect) + local w = parent_rect.width + return BASELINE_OFFSET + (w+1)//2 - 34 +end + +function launch_mass_remove() + local vs = dfhack.gui.getDFViewscreen(true) + gui.simulateInput(vs,'LEAVESCREEN') + dfhack.run_command('gui/mass-remove') +end + local function get_first_job(bld) if not bld then return end if #bld.jobs ~= 1 then return end @@ -383,6 +401,96 @@ function MassRemoveScreen:onDismiss() view = nil end + +-- -------------------------------- +-- MassRemoveToolbarOverlay +-- + +MassRemoveToolbarOverlay = defclass(MassRemoveToolbarOverlay, overlay.OverlayWidget) +MassRemoveToolbarOverlay.ATTRS{ + desc='Adds widgets to the erase interface to open the mass removal tool', + default_pos={x=BASELINE_OFFSET, y=-4}, + default_enabled=true, + viewscreens={ + 'dwarfmode/Designate/ERASE' + }, + frame={w=26, h=11}, +} + +function MassRemoveToolbarOverlay:init() + local button_chars = { + {218, 196, 196, 191}, + {179, 'M', 'R', 179}, + {192, 196, 196, 217}, + } + + self:addviews{ + widgets.Panel{ + frame={t=0, r=0, w=26, h=6}, + frame_style=gui.FRAME_PANEL, + frame_background=gui.CLEAR_PEN, + frame_inset={l=1, r=1}, + visible=function() return not not self.subviews.icon:getMousePos() end, + subviews={ + widgets.Label{ + text={ + 'Open mass removal\ninterface.', NEWLINE, + NEWLINE, + {text='Hotkey: ', pen=COLOR_GRAY}, {key='CUSTOM_M'}, + }, + }, + }, + }, + widgets.Panel{ + view_id='icon', + frame={b=0, r=22, w=4, h=3}, + subviews={ + widgets.Label{ + text=widgets.makeButtonLabelText{ + chars=button_chars, + pens=COLOR_GRAY, + tileset=toolbar_textures, + tileset_offset=1, + tileset_stride=8, + }, + on_click=launch_mass_remove, + visible=function () return not self.subviews.icon:getMousePos() end, + }, + widgets.Label{ + text=widgets.makeButtonLabelText{ + chars=button_chars, + pens={ + {COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE}, + {COLOR_WHITE, COLOR_GRAY, COLOR_GRAY, COLOR_WHITE}, + {COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE}, + }, + tileset=toolbar_textures, + tileset_offset=5, + tileset_stride=8, + }, + on_click=launch_mass_remove, + visible=function() return not not self.subviews.icon:getMousePos() end, + }, + }, + }, + } +end + +function MassRemoveToolbarOverlay:preUpdateLayout(parent_rect) + self.frame.w = get_l_offset(parent_rect) - BASELINE_OFFSET + 18 +end + +function MassRemoveToolbarOverlay:onInput(keys) + if keys.CUSTOM_M then + launch_mass_remove() + return true + end + return MassRemoveToolbarOverlay.super.onInput(self, keys) +end + +OVERLAY_WIDGETS = {massremovetoolbar=MassRemoveToolbarOverlay} + + if dfhack_flags.module then return end diff --git a/mass-remove.lua b/mass-remove.lua deleted file mode 100644 index 1c5188749..000000000 --- a/mass-remove.lua +++ /dev/null @@ -1,113 +0,0 @@ ---@ module = true - -local gui = require('gui') -local overlay = require('plugins.overlay') -local widgets = require('gui.widgets') - -local toolbar_textures = (dfhack.textures.loadTileset('hack/data/art/mass_remove_toolbar.png', 8,12)) - -local BASELINE_OFFSET = 42 - -local function get_l_offset(parent_rect) - local w = parent_rect.width - return BASELINE_OFFSET + (w+1)//2 - 34 -end - -function launch_mass_remove() - local vs = dfhack.gui.getDFViewscreen(true) - gui.simulateInput(vs,'LEAVESCREEN') - dfhack.run_command('gui/mass-remove') -end - - --- -------------------------------- --- MassRemoveToolbarOverlay --- - -MassRemoveToolbarOverlay = defclass(MassRemoveToolbarOverlay, overlay.OverlayWidget) -MassRemoveToolbarOverlay.ATTRS{ - desc='Adds widgets to the erase interface to open the mass removal tool', - default_pos={x=BASELINE_OFFSET, y=-4}, - default_enabled=true, - viewscreens={ - 'dwarfmode/Designate/ERASE' - }, - frame={w=26, h=11}, -} - -function MassRemoveToolbarOverlay:init() - local button_chars = { - {218, 196, 196, 191}, - {179, 'M', 'R', 179}, - {192, 196, 196, 217}, - } - - self:addviews{ - widgets.Panel{ - frame={t=0, r=0, w=26, h=6}, - frame_style=gui.FRAME_PANEL, - frame_background=gui.CLEAR_PEN, - frame_inset={l=1, r=1}, - visible=function() return not not self.subviews.icon:getMousePos() end, - subviews={ - widgets.Label{ - text={ - 'Open mass removal\ninterface.', NEWLINE, - NEWLINE, - {text='Hotkey: ', pen=COLOR_GRAY}, {key='CUSTOM_M'}, - }, - }, - }, - }, - widgets.Panel{ - view_id='icon', - frame={b=0, r=22, w=4, h=3}, - subviews={ - widgets.Label{ - text=widgets.makeButtonLabelText{ - chars=button_chars, - pens=COLOR_GRAY, - tileset=toolbar_textures, - tileset_offset=1, - tileset_stride=8, - }, - on_click=launch_mass_remove, - visible=function () return not self.subviews.icon:getMousePos() end, - }, - widgets.Label{ - text=widgets.makeButtonLabelText{ - chars=button_chars, - pens={ - {COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE}, - {COLOR_WHITE, COLOR_GRAY, COLOR_GRAY, COLOR_WHITE}, - {COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE}, - }, - tileset=toolbar_textures, - tileset_offset=5, - tileset_stride=8, - }, - on_click=launch_mass_remove, - visible=function() return not not self.subviews.icon:getMousePos() end, - }, - }, - }, - } -end - -function MassRemoveToolbarOverlay:preUpdateLayout(parent_rect) - self.frame.w = get_l_offset(parent_rect) - BASELINE_OFFSET + 18 -end - -function MassRemoveToolbarOverlay:onInput(keys) - if keys.CUSTOM_M then - launch_mass_remove() - return true - end - return MassRemoveToolbarOverlay.super.onInput(self, keys) -end - -OVERLAY_WIDGETS = {massremovetoolbar=MassRemoveToolbarOverlay} - -if dfhack_flags.module then - return -end From 74237a24ef616b111c85066090af20c994334181 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Sat, 22 Mar 2025 19:12:52 -0500 Subject: [PATCH 11/18] clean up --- gui/mass-remove.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/mass-remove.lua b/gui/mass-remove.lua index a141874f3..df6ad4ed8 100644 --- a/gui/mass-remove.lua +++ b/gui/mass-remove.lua @@ -23,7 +23,7 @@ end function launch_mass_remove() local vs = dfhack.gui.getDFViewscreen(true) gui.simulateInput(vs,'LEAVESCREEN') - dfhack.run_command('gui/mass-remove') + MassRemoveScreen{}:show() end local function get_first_job(bld) From 8e21b02c0737abb8591d41c2b492d01b5118a309 Mon Sep 17 00:00:00 2001 From: Squid Coder <92821989+realSquidCoder@users.noreply.github.com> Date: Sat, 22 Mar 2025 19:21:03 -0500 Subject: [PATCH 12/18] Apply suggestions from code review Co-authored-by: Myk --- docs/gui/mass-remove.rst | 2 +- gui/mass-remove.lua | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/gui/mass-remove.rst b/docs/gui/mass-remove.rst index 66e3b759f..01776ce7c 100644 --- a/docs/gui/mass-remove.rst +++ b/docs/gui/mass-remove.rst @@ -30,6 +30,6 @@ framework. massremovetoolbar ~~~~~~~~~~~~~~~~~ -The mass-remove.massremovetoolbar overlay adds a button to the toolbar at the bottom of the +The ``mass-remove.massremovetoolbar`` overlay adds a button to the toolbar at the bottom of the screen when eraser mode is active. It allows you to conveniently open the ``gui/mass-remove`` interface. diff --git a/gui/mass-remove.lua b/gui/mass-remove.lua index df6ad4ed8..512324b0f 100644 --- a/gui/mass-remove.lua +++ b/gui/mass-remove.lua @@ -2,7 +2,7 @@ --@ module = true -local toolbar_textures = (dfhack.textures.loadTileset('hack/data/art/mass_remove_toolbar.png', 8,12)) +local toolbar_textures = dfhack.textures.loadTileset('hack/data/art/mass_remove_toolbar.png', 8, 12) local BASELINE_OFFSET = 42 @@ -408,12 +408,10 @@ end MassRemoveToolbarOverlay = defclass(MassRemoveToolbarOverlay, overlay.OverlayWidget) MassRemoveToolbarOverlay.ATTRS{ - desc='Adds widgets to the erase interface to open the mass removal tool', + desc='Adds a button to the erase toolbar to open the mass removal tool', default_pos={x=BASELINE_OFFSET, y=-4}, default_enabled=true, - viewscreens={ - 'dwarfmode/Designate/ERASE' - }, + viewscreens='dwarfmode/Designate/ERASE', frame={w=26, h=11}, } @@ -434,7 +432,8 @@ function MassRemoveToolbarOverlay:init() subviews={ widgets.Label{ text={ - 'Open mass removal\ninterface.', NEWLINE, + 'Open mass removal', NEWLINE, + 'interface.', NEWLINE, NEWLINE, {text='Hotkey: ', pen=COLOR_GRAY}, {key='CUSTOM_M'}, }, From db1ce8faf42720a90469979d046e9044e603fc8e Mon Sep 17 00:00:00 2001 From: Squid Coder <92821989+realSquidCoder@users.noreply.github.com> Date: Sat, 22 Mar 2025 19:21:21 -0500 Subject: [PATCH 13/18] Apply suggestions from code review Co-authored-by: Myk --- docs/gui/mass-remove.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/gui/mass-remove.rst b/docs/gui/mass-remove.rst index 01776ce7c..ae3edc287 100644 --- a/docs/gui/mass-remove.rst +++ b/docs/gui/mass-remove.rst @@ -19,8 +19,6 @@ Usage :: gui/mass-remove - - Overlay ------- From 26f05180bf3371eedc6a0b3c2c1d667968c49247 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Sat, 22 Mar 2025 19:26:57 -0500 Subject: [PATCH 14/18] Update from code review --- gui/mass-remove.lua | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/gui/mass-remove.lua b/gui/mass-remove.lua index 512324b0f..c63b5bbf9 100644 --- a/gui/mass-remove.lua +++ b/gui/mass-remove.lua @@ -15,11 +15,6 @@ local overlay = require('plugins.overlay') local function noop() end -local function get_l_offset(parent_rect) - local w = parent_rect.width - return BASELINE_OFFSET + (w+1)//2 - 34 -end - function launch_mass_remove() local vs = dfhack.gui.getDFViewscreen(true) gui.simulateInput(vs,'LEAVESCREEN') @@ -428,7 +423,7 @@ function MassRemoveToolbarOverlay:init() frame_style=gui.FRAME_PANEL, frame_background=gui.CLEAR_PEN, frame_inset={l=1, r=1}, - visible=function() return not not self.subviews.icon:getMousePos() end, + visible=function() return self.subviews.icon:getMousePos() end, subviews={ widgets.Label{ text={ @@ -468,7 +463,7 @@ function MassRemoveToolbarOverlay:init() tileset_stride=8, }, on_click=launch_mass_remove, - visible=function() return not not self.subviews.icon:getMousePos() end, + visible=function() return self.subviews.icon:getMousePos() end, }, }, }, @@ -476,7 +471,7 @@ function MassRemoveToolbarOverlay:init() end function MassRemoveToolbarOverlay:preUpdateLayout(parent_rect) - self.frame.w = get_l_offset(parent_rect) - BASELINE_OFFSET + 18 + self.frame.w = (parent_rect.width+1)//2 - 16 end function MassRemoveToolbarOverlay:onInput(keys) From 1c86714fc04d2a0e9617f824f690760ccb84da4c Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Sat, 22 Mar 2025 19:47:21 -0500 Subject: [PATCH 15/18] remove Baseline offset --- gui/mass-remove.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gui/mass-remove.lua b/gui/mass-remove.lua index c63b5bbf9..1276b12da 100644 --- a/gui/mass-remove.lua +++ b/gui/mass-remove.lua @@ -4,8 +4,6 @@ local toolbar_textures = dfhack.textures.loadTileset('hack/data/art/mass_remove_toolbar.png', 8, 12) -local BASELINE_OFFSET = 42 - local gui = require('gui') local guidm = require('gui.dwarfmode') local utils = require('utils') @@ -404,7 +402,7 @@ end MassRemoveToolbarOverlay = defclass(MassRemoveToolbarOverlay, overlay.OverlayWidget) MassRemoveToolbarOverlay.ATTRS{ desc='Adds a button to the erase toolbar to open the mass removal tool', - default_pos={x=BASELINE_OFFSET, y=-4}, + default_pos={x=42, y=-4}, default_enabled=true, viewscreens='dwarfmode/Designate/ERASE', frame={w=26, h=11}, From 040da8be760f6096aa17a1e5bd3830101f6c4b09 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Sat, 22 Mar 2025 19:50:05 -0500 Subject: [PATCH 16/18] Update mass-remove.lua --- gui/mass-remove.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/mass-remove.lua b/gui/mass-remove.lua index 1276b12da..fc4546b46 100644 --- a/gui/mass-remove.lua +++ b/gui/mass-remove.lua @@ -16,7 +16,7 @@ end function launch_mass_remove() local vs = dfhack.gui.getDFViewscreen(true) gui.simulateInput(vs,'LEAVESCREEN') - MassRemoveScreen{}:show() + dfhack.run_script('gui/mass-remove') end local function get_first_job(bld) From 3da987da452e09ee6e16c2c0d6be73e3f5d51796 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Sat, 22 Mar 2025 19:55:38 -0500 Subject: [PATCH 17/18] fix docs error --- docs/gui/mass-remove.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/gui/mass-remove.rst b/docs/gui/mass-remove.rst index ae3edc287..1a8ea4b54 100644 --- a/docs/gui/mass-remove.rst +++ b/docs/gui/mass-remove.rst @@ -19,6 +19,7 @@ Usage :: gui/mass-remove + Overlay ------- From c14f328cd45640a2e44378ebd37b00e2b06b19c5 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Sat, 22 Mar 2025 20:01:59 -0500 Subject: [PATCH 18/18] Update changelog.txt --- changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index c4cb15b52..56aa6b584 100644 --- a/changelog.txt +++ b/changelog.txt @@ -29,7 +29,7 @@ Template for new versions: ## New Tools ## New Features - +- `gui/mass-remove`: added a button to the bottom toolbar when eraser mode is active for launching `gui/mass-remove` - `idle-crafting`: default to only considering happy and ecstatic units for the highest need threshold ## Fixes