From 88ff276cf07b1743fdea073a4fbfef7f1c0246af Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Thu, 20 Mar 2025 08:33:36 -0500 Subject: [PATCH 01/13] Make sitemap toolbar button overlay --- sitemap.lua | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 sitemap.lua diff --git a/sitemap.lua b/sitemap.lua new file mode 100644 index 000000000..25af82321 --- /dev/null +++ b/sitemap.lua @@ -0,0 +1,100 @@ +--@ 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/sitemap_toolbar.png', 8,12)) + +function launch_sitemap() + dfhack.run_command('gui/sitemap') +end + + +-- -------------------------------- +-- SitemapToolbarOverlay +-- + +SitemapToolbarOverlay = defclass(SitemapToolbarOverlay, overlay.OverlayWidget) +SitemapToolbarOverlay.ATTRS{ + desc='Adds widgets to the erase interface to open the mass removal tool', + default_pos={x=35, y=-1}, + default_enabled=true, + viewscreens={ + 'dwarfmode' + }, + frame={w=28, h=9}, +} + +function SitemapToolbarOverlay:init() + local button_chars = { + {218, 196, 196, 191}, + {179, '-', 'O', 179}, + {192, 196, 196, 217}, + } + + self:addviews{ + widgets.Panel{ + frame={t=0, r=0, w=26, h=5}, + 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 the sitemap menu.', NEWLINE, + NEWLINE, + {text='Hotkey: ', pen=COLOR_GRAY}, {key='CUSTOM_CTRL_G'}, + }, + }, + }, + }, + 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_sitemap, + 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_sitemap, + visible=function() return not not self.subviews.icon:getMousePos() end, + }, + }, + }, + } +end + +function SitemapToolbarOverlay:onInput(keys) + if keys.CUSTOM_CTRL_G then + launch_sitemap() + return true + end + return SitemapToolbarOverlay.super.onInput(self, keys) +end + +OVERLAY_WIDGETS = {sitemaptoolbar=SitemapToolbarOverlay} + +if dfhack_flags.module then + return +end From 73df00c359ff4fd71584e7a201d78977c49942c2 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Thu, 20 Mar 2025 08:49:06 -0500 Subject: [PATCH 02/13] clean up --- sitemap.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sitemap.lua b/sitemap.lua index 25af82321..066a8b8d5 100644 --- a/sitemap.lua +++ b/sitemap.lua @@ -35,7 +35,7 @@ function SitemapToolbarOverlay:init() self:addviews{ widgets.Panel{ - frame={t=0, r=0, w=26, h=5}, + frame={t=0, l=0, w=26, h=5}, frame_style=gui.FRAME_PANEL, frame_background=gui.CLEAR_PEN, frame_inset={l=1, r=1}, @@ -52,7 +52,7 @@ function SitemapToolbarOverlay:init() }, widgets.Panel{ view_id='icon', - frame={b=0, r=22, w=4, h=3}, + frame={b=0, l=0, w=4, h=3}, subviews={ widgets.Label{ text=widgets.makeButtonLabelText{ From b27095f6bb3f9d7782936d37d48457f6b1004452 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Sat, 22 Mar 2025 19:12:09 -0500 Subject: [PATCH 03/13] merge into the real deal --- gui/sitemap.lua | 93 ++++++++++++++++++++++++++++++++++++++++++++ sitemap.lua | 100 ------------------------------------------------ 2 files changed, 93 insertions(+), 100 deletions(-) delete mode 100644 sitemap.lua diff --git a/gui/sitemap.lua b/gui/sitemap.lua index 671212f91..666e92d84 100644 --- a/gui/sitemap.lua +++ b/gui/sitemap.lua @@ -3,6 +3,13 @@ local gui = require('gui') local utils = require('utils') local widgets = require('gui.widgets') +local overlay = require('plugins.overlay') + +local toolbar_textures = (dfhack.textures.loadTileset('hack/data/art/sitemap_toolbar.png', 8,12)) + +function launch_sitemap() + SitemapScreen{}:show() +end -- -- Sitemap @@ -353,6 +360,92 @@ function SitemapScreen:onDismiss() view = nil end + +-- -------------------------------- +-- SitemapToolbarOverlay +-- + +SitemapToolbarOverlay = defclass(SitemapToolbarOverlay, overlay.OverlayWidget) +SitemapToolbarOverlay.ATTRS{ + desc='Adds widgets to the erase interface to open the mass removal tool', + default_pos={x=35, y=-1}, + default_enabled=true, + viewscreens={ + 'dwarfmode' + }, + frame={w=28, h=9}, +} + +function SitemapToolbarOverlay:init() + local button_chars = { + {218, 196, 196, 191}, + {179, '-', 'O', 179}, + {192, 196, 196, 217}, + } + + self:addviews{ + widgets.Panel{ + frame={t=0, l=0, w=26, h=5}, + 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 the sitemap menu.', NEWLINE, + NEWLINE, + {text='Hotkey: ', pen=COLOR_GRAY}, {key='CUSTOM_CTRL_G'}, + }, + }, + }, + }, + widgets.Panel{ + view_id='icon', + frame={b=0, l=0, 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_sitemap, + 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_sitemap, + visible=function() return not not self.subviews.icon:getMousePos() end, + }, + }, + }, + } +end + +function SitemapToolbarOverlay:onInput(keys) + if keys.CUSTOM_CTRL_G then + launch_sitemap() + return true + end + return SitemapToolbarOverlay.super.onInput(self, keys) +end + +OVERLAY_WIDGETS = {sitemaptoolbar=SitemapToolbarOverlay} + + if dfhack_flags.module then return end diff --git a/sitemap.lua b/sitemap.lua deleted file mode 100644 index 066a8b8d5..000000000 --- a/sitemap.lua +++ /dev/null @@ -1,100 +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/sitemap_toolbar.png', 8,12)) - -function launch_sitemap() - dfhack.run_command('gui/sitemap') -end - - --- -------------------------------- --- SitemapToolbarOverlay --- - -SitemapToolbarOverlay = defclass(SitemapToolbarOverlay, overlay.OverlayWidget) -SitemapToolbarOverlay.ATTRS{ - desc='Adds widgets to the erase interface to open the mass removal tool', - default_pos={x=35, y=-1}, - default_enabled=true, - viewscreens={ - 'dwarfmode' - }, - frame={w=28, h=9}, -} - -function SitemapToolbarOverlay:init() - local button_chars = { - {218, 196, 196, 191}, - {179, '-', 'O', 179}, - {192, 196, 196, 217}, - } - - self:addviews{ - widgets.Panel{ - frame={t=0, l=0, w=26, h=5}, - 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 the sitemap menu.', NEWLINE, - NEWLINE, - {text='Hotkey: ', pen=COLOR_GRAY}, {key='CUSTOM_CTRL_G'}, - }, - }, - }, - }, - widgets.Panel{ - view_id='icon', - frame={b=0, l=0, 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_sitemap, - 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_sitemap, - visible=function() return not not self.subviews.icon:getMousePos() end, - }, - }, - }, - } -end - -function SitemapToolbarOverlay:onInput(keys) - if keys.CUSTOM_CTRL_G then - launch_sitemap() - return true - end - return SitemapToolbarOverlay.super.onInput(self, keys) -end - -OVERLAY_WIDGETS = {sitemaptoolbar=SitemapToolbarOverlay} - -if dfhack_flags.module then - return -end From 9ae33be58dcf7d1b76d774a378fa65a5938df83f Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Sat, 22 Mar 2025 19:18:13 -0500 Subject: [PATCH 04/13] Add overlay docs --- docs/gui/sitemap.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/gui/sitemap.rst b/docs/gui/sitemap.rst index ed1d89521..a74ea6629 100644 --- a/docs/gui/sitemap.rst +++ b/docs/gui/sitemap.rst @@ -24,3 +24,17 @@ Usage :: gui/sitemap + + +Overlay +------- + +This tool also provides one overlay that is managed by the `overlay` +framework. + +sitemaptoolbar +~~~~~~~~~~~~~~~~~ + +The sitemap.sitemaptoolbar overlay adds a button to the toolbar at the bottom left corner of the +screen with the other menu buttons. It allows you to conveniently open the ``gui/sitemap`` +interface. From 925ac665531d1f58f9a59dbb5fb1005677956d9d Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Sat, 22 Mar 2025 19:52:03 -0500 Subject: [PATCH 05/13] Update sitemap.lua --- gui/sitemap.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/sitemap.lua b/gui/sitemap.lua index 666e92d84..a54f50faa 100644 --- a/gui/sitemap.lua +++ b/gui/sitemap.lua @@ -8,7 +8,7 @@ local overlay = require('plugins.overlay') local toolbar_textures = (dfhack.textures.loadTileset('hack/data/art/sitemap_toolbar.png', 8,12)) function launch_sitemap() - SitemapScreen{}:show() + dfhack.run_script('gui/sitemap') end -- From 51a49788be73e4981f1dea525fdd40e0a79f4328 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Sat, 22 Mar 2025 20:11:23 -0500 Subject: [PATCH 06/13] Update changelog.txt --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index 56aa6b584..b24a1ff32 100644 --- a/changelog.txt +++ b/changelog.txt @@ -31,6 +31,7 @@ Template for new versions: ## 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 +- `gui/sitemap`: added a button to the toolbar at the bottom left corner of the screen with the other menu buttons for launching `gui/sitemap` ## Fixes From 91b9fc22adc6d5bb1abccea031826358ee7a8ab6 Mon Sep 17 00:00:00 2001 From: Squid Coder <92821989+realSquidCoder@users.noreply.github.com> Date: Sat, 22 Mar 2025 20:14:06 -0500 Subject: [PATCH 07/13] Apply suggestion from code review Co-authored-by: Myk --- docs/gui/sitemap.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/gui/sitemap.rst b/docs/gui/sitemap.rst index a74ea6629..870130b3f 100644 --- a/docs/gui/sitemap.rst +++ b/docs/gui/sitemap.rst @@ -35,6 +35,6 @@ framework. sitemaptoolbar ~~~~~~~~~~~~~~~~~ -The sitemap.sitemaptoolbar overlay adds a button to the toolbar at the bottom left corner of the +The ``gui/sitemap.toolbar`` overlay adds a button to the toolbar at the bottom left corner of the screen with the other menu buttons. It allows you to conveniently open the ``gui/sitemap`` interface. From 8053e515f3f28c8b7c3da4a2377c0dbef60a6266 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Sat, 22 Mar 2025 20:18:12 -0500 Subject: [PATCH 08/13] update the overlay name --- docs/gui/sitemap.rst | 5 ++--- gui/sitemap.lua | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/gui/sitemap.rst b/docs/gui/sitemap.rst index 870130b3f..acdb92ae8 100644 --- a/docs/gui/sitemap.rst +++ b/docs/gui/sitemap.rst @@ -25,15 +25,14 @@ Usage gui/sitemap - Overlay ------- This tool also provides one overlay that is managed by the `overlay` framework. -sitemaptoolbar -~~~~~~~~~~~~~~~~~ +toolbar +~~~~~~~ The ``gui/sitemap.toolbar`` overlay adds a button to the toolbar at the bottom left corner of the screen with the other menu buttons. It allows you to conveniently open the ``gui/sitemap`` diff --git a/gui/sitemap.lua b/gui/sitemap.lua index a54f50faa..8a3e30dd1 100644 --- a/gui/sitemap.lua +++ b/gui/sitemap.lua @@ -443,7 +443,7 @@ function SitemapToolbarOverlay:onInput(keys) return SitemapToolbarOverlay.super.onInput(self, keys) end -OVERLAY_WIDGETS = {sitemaptoolbar=SitemapToolbarOverlay} +OVERLAY_WIDGETS = {toolbar=SitemapToolbarOverlay} if dfhack_flags.module then From b307462cd98b7d82e7c7fb993c38c486b52de37d Mon Sep 17 00:00:00 2001 From: Squid Coder <92821989+realSquidCoder@users.noreply.github.com> Date: Sat, 22 Mar 2025 21:02:45 -0500 Subject: [PATCH 09/13] Apply suggestions from code review Co-authored-by: Myk --- gui/sitemap.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/gui/sitemap.lua b/gui/sitemap.lua index 8a3e30dd1..38e3f4d67 100644 --- a/gui/sitemap.lua +++ b/gui/sitemap.lua @@ -5,7 +5,7 @@ local utils = require('utils') local widgets = require('gui.widgets') local overlay = require('plugins.overlay') -local toolbar_textures = (dfhack.textures.loadTileset('hack/data/art/sitemap_toolbar.png', 8,12)) +local toolbar_textures = dfhack.textures.loadTileset('hack/data/art/sitemap_toolbar.png', 8, 12) function launch_sitemap() dfhack.run_script('gui/sitemap') @@ -367,12 +367,10 @@ end SitemapToolbarOverlay = defclass(SitemapToolbarOverlay, overlay.OverlayWidget) SitemapToolbarOverlay.ATTRS{ - desc='Adds widgets to the erase interface to open the mass removal tool', + desc='Adds a button to the toolbar at the bottom left corner of the screen with the other menu buttons.', default_pos={x=35, y=-1}, default_enabled=true, - viewscreens={ - 'dwarfmode' - }, + viewscreens='dwarfmode', frame={w=28, h=9}, } @@ -389,11 +387,12 @@ function SitemapToolbarOverlay: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={ - 'Open the sitemap menu.', NEWLINE, + 'Open the general search', NEWLINE, + 'interface.', NEWLINE, NEWLINE, {text='Hotkey: ', pen=COLOR_GRAY}, {key='CUSTOM_CTRL_G'}, }, From 993f934cd23c4329d5171273d2b7ad61754ef590 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Sat, 22 Mar 2025 21:03:45 -0500 Subject: [PATCH 10/13] remove keybind, (its already handled) --- gui/sitemap.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/gui/sitemap.lua b/gui/sitemap.lua index 38e3f4d67..c4010d867 100644 --- a/gui/sitemap.lua +++ b/gui/sitemap.lua @@ -435,10 +435,6 @@ function SitemapToolbarOverlay:init() end function SitemapToolbarOverlay:onInput(keys) - if keys.CUSTOM_CTRL_G then - launch_sitemap() - return true - end return SitemapToolbarOverlay.super.onInput(self, keys) end From 654b81e7823f63111637e393e7764a760d303700 Mon Sep 17 00:00:00 2001 From: Squid Coder <92821989+realSquidCoder@users.noreply.github.com> Date: Sat, 22 Mar 2025 21:08:10 -0500 Subject: [PATCH 11/13] Apply suggestions from code review Co-authored-by: Myk --- docs/gui/sitemap.rst | 4 ++-- gui/sitemap.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/gui/sitemap.rst b/docs/gui/sitemap.rst index acdb92ae8..493f3ba5f 100644 --- a/docs/gui/sitemap.rst +++ b/docs/gui/sitemap.rst @@ -31,8 +31,8 @@ Overlay This tool also provides one overlay that is managed by the `overlay` framework. -toolbar -~~~~~~~ +gui/sitemap.toolbar +~~~~~~~~~~~~~~~~~~~ The ``gui/sitemap.toolbar`` overlay adds a button to the toolbar at the bottom left corner of the screen with the other menu buttons. It allows you to conveniently open the ``gui/sitemap`` diff --git a/gui/sitemap.lua b/gui/sitemap.lua index c4010d867..1b8247c2e 100644 --- a/gui/sitemap.lua +++ b/gui/sitemap.lua @@ -367,7 +367,7 @@ end SitemapToolbarOverlay = defclass(SitemapToolbarOverlay, overlay.OverlayWidget) SitemapToolbarOverlay.ATTRS{ - desc='Adds a button to the toolbar at the bottom left corner of the screen with the other menu buttons.', + desc='Adds a button to the toolbar at the bottom left corner of the screen with the other menu buttons for launching gui/sitemap, default_pos={x=35, y=-1}, default_enabled=true, viewscreens='dwarfmode', From 81b3592bb29b5c9a1daa373ba121a5de4061728e Mon Sep 17 00:00:00 2001 From: Squid Coder <92821989+realSquidCoder@users.noreply.github.com> Date: Sat, 22 Mar 2025 21:10:54 -0500 Subject: [PATCH 12/13] Fix typo --- gui/sitemap.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/sitemap.lua b/gui/sitemap.lua index 1b8247c2e..b696f1c69 100644 --- a/gui/sitemap.lua +++ b/gui/sitemap.lua @@ -367,7 +367,7 @@ end SitemapToolbarOverlay = defclass(SitemapToolbarOverlay, overlay.OverlayWidget) SitemapToolbarOverlay.ATTRS{ - desc='Adds a button to the toolbar at the bottom left corner of the screen with the other menu buttons for launching gui/sitemap, + desc='Adds a button to the toolbar at the bottom left corner of the screen with the other menu buttons for launching gui/sitemap', default_pos={x=35, y=-1}, default_enabled=true, viewscreens='dwarfmode', From 1dfa37279c68d7737ab60018875c1a52839d946d Mon Sep 17 00:00:00 2001 From: Squid Coder <92821989+realSquidCoder@users.noreply.github.com> Date: Sat, 22 Mar 2025 21:13:04 -0500 Subject: [PATCH 13/13] Clean up Co-authored-by: Myk --- gui/sitemap.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/sitemap.lua b/gui/sitemap.lua index b696f1c69..ffc4082c5 100644 --- a/gui/sitemap.lua +++ b/gui/sitemap.lua @@ -367,7 +367,7 @@ end SitemapToolbarOverlay = defclass(SitemapToolbarOverlay, overlay.OverlayWidget) SitemapToolbarOverlay.ATTRS{ - desc='Adds a button to the toolbar at the bottom left corner of the screen with the other menu buttons for launching gui/sitemap', + desc='Adds a button to the toolbar at the bottom left corner of the screen for launching gui/sitemap.', default_pos={x=35, y=-1}, default_enabled=true, viewscreens='dwarfmode',