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 diff --git a/docs/gui/sitemap.rst b/docs/gui/sitemap.rst index ed1d89521..493f3ba5f 100644 --- a/docs/gui/sitemap.rst +++ b/docs/gui/sitemap.rst @@ -24,3 +24,16 @@ Usage :: gui/sitemap + +Overlay +------- + +This tool also provides one overlay that is managed by the `overlay` +framework. + +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`` +interface. diff --git a/gui/sitemap.lua b/gui/sitemap.lua index 671212f91..ffc4082c5 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() + dfhack.run_script('gui/sitemap') +end -- -- Sitemap @@ -353,6 +360,87 @@ function SitemapScreen:onDismiss() view = nil end + +-- -------------------------------- +-- SitemapToolbarOverlay +-- + +SitemapToolbarOverlay = defclass(SitemapToolbarOverlay, overlay.OverlayWidget) +SitemapToolbarOverlay.ATTRS{ + 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', + 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 self.subviews.icon:getMousePos() end, + subviews={ + widgets.Label{ + text={ + 'Open the general search', NEWLINE, + 'interface.', 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) + return SitemapToolbarOverlay.super.onInput(self, keys) +end + +OVERLAY_WIDGETS = {toolbar=SitemapToolbarOverlay} + + if dfhack_flags.module then return end