From 236c54eda2df5e35129e97546354dd57e03a27cb Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Fri, 28 Mar 2025 15:25:42 -0500 Subject: [PATCH 1/5] Add toolbar button for `gui/design` --- gui/design.lua | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/gui/design.lua b/gui/design.lua index 103ab59c8..018a4ec34 100644 --- a/gui/design.lua +++ b/gui/design.lua @@ -38,6 +38,13 @@ local util = reqscript('internal/design/util') local utils = require('utils') local widgets = require('gui.widgets') +local toolbar_textures = dfhack.textures.loadTileset('hack/data/art/design_toolbar.png', 8, 12) + +function launch_design() + dfhack.run_script('gui/design') +end + + local Point = util.Point local getMousePoint = util.getMousePoint @@ -1565,6 +1572,90 @@ function DesignScreen:onDismiss() view = nil end + +-- -------------------------------- +-- DesignToolbarOverlay +-- + +DesignToolbarOverlay = defclass(DesignToolbarOverlay, overlay.OverlayWidget) +DesignToolbarOverlay.ATTRS{ + desc='Adds a button to the toolbar at the bottom of the screen for launching gui/design.', + default_pos={x=40, y=-1}, + default_enabled=true, + viewscreens='dwarfmode', + frame={w=28, h=10}, +} + +function DesignToolbarOverlay:init() + local button_chars = { + {218, 196, 196, 191}, + {179, '[', ']', 179}, + {192, 196, 196, 217}, + } + + self:addviews{ + widgets.Panel{ + frame={t=0, l=0, w=20, h=6}, + frame_style=gui.FRAME_PANEL, + frame_background=gui.CLEAR_PEN, + frame_inset={l=1, r=1}, + visible=function() return self.subviews.icon:getMousePos() end, + subviews={ + widgets.Label{ + text={ + 'Open the design', NEWLINE, + 'interface.', NEWLINE, + NEWLINE, + {text='Hotkey: ', pen=COLOR_GRAY}, {key='CUSTOM_CTRL_D'}, + }, + }, + }, + }, + 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, COLOR_GRAY, COLOR_GRAY, COLOR_GRAY}, + {COLOR_GRAY, COLOR_BLUE, COLOR_BLUE, COLOR_GRAY}, + {COLOR_GRAY, COLOR_GRAY, COLOR_GRAY, 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_BLUE, COLOR_BLUE, COLOR_WHITE}, + {COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE}, + }, + tileset=toolbar_textures, + tileset_offset=5, + tileset_stride=8, + }, + on_click=launch_design, + visible=function() return self.subviews.icon:getMousePos() end, + }, + }, + }, + } +end + +function DesignToolbarOverlay:onInput(keys) + return DesignToolbarOverlay.super.onInput(self, keys) +end + +OVERLAY_WIDGETS = {toolbar=DesignToolbarOverlay} + if dfhack_flags.module then return end if not dfhack.isMapLoaded() then From a1e850078dc76444b6efdc159d993e885a2468d3 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Fri, 28 Mar 2025 15:28:17 -0500 Subject: [PATCH 2/5] Update changelog.txt --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index cd1830ff1..86773995e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -32,6 +32,7 @@ Template for new versions: - `gui/mass-remove`: add 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`: add a button to the toolbar at the bottom left corner of the screen for launching `gui/sitemap` +- `gui/design`: add a button to the toolbar at the bottom left corner of the screen for launching `gui/design` ## Fixes - `idle-crafting`: check that units still have crafting needs before creating a job for them From 00a13243cede649de9c823095fc594b4696e90e8 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Fri, 28 Mar 2025 15:31:54 -0500 Subject: [PATCH 3/5] Fix the positioning --- gui/design.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/design.lua b/gui/design.lua index 018a4ec34..61d71da79 100644 --- a/gui/design.lua +++ b/gui/design.lua @@ -1580,7 +1580,7 @@ end DesignToolbarOverlay = defclass(DesignToolbarOverlay, overlay.OverlayWidget) DesignToolbarOverlay.ATTRS{ desc='Adds a button to the toolbar at the bottom of the screen for launching gui/design.', - default_pos={x=40, y=-1}, + default_pos={x=50, y=-1}, default_enabled=true, viewscreens='dwarfmode', frame={w=28, h=10}, From d17b1cace7220b40242db9298b35c0fff3586932 Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Fri, 28 Mar 2025 15:45:45 -0500 Subject: [PATCH 4/5] fix up a non-bug --- gui/design.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/design.lua b/gui/design.lua index 61d71da79..9f409ebea 100644 --- a/gui/design.lua +++ b/gui/design.lua @@ -1627,7 +1627,7 @@ function DesignToolbarOverlay:init() tileset_offset=1, tileset_stride=8, }, - on_click=launch_sitemap, + on_click=launch_design, visible=function () return not self.subviews.icon:getMousePos() end, }, widgets.Label{ From 1a101c224f82046bec34f56ef9739278fdd942ad Mon Sep 17 00:00:00 2001 From: Squid Coder Date: Wed, 2 Apr 2025 12:43:47 -0500 Subject: [PATCH 5/5] Fix the overlays being overwritten --- gui/design.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gui/design.lua b/gui/design.lua index 9f409ebea..a106655e5 100644 --- a/gui/design.lua +++ b/gui/design.lua @@ -175,11 +175,6 @@ function RightClickOverlay:onInput(keys) end end -OVERLAY_WIDGETS = { - dimensions=DimensionsOverlay, - rightclick=RightClickOverlay, -} - --- --- HelpWindow --- @@ -1654,7 +1649,11 @@ function DesignToolbarOverlay:onInput(keys) return DesignToolbarOverlay.super.onInput(self, keys) end -OVERLAY_WIDGETS = {toolbar=DesignToolbarOverlay} +OVERLAY_WIDGETS = { + dimensions=DimensionsOverlay, + rightclick=RightClickOverlay, + toolbar=DesignToolbarOverlay +} if dfhack_flags.module then return end