Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions docs/gui/sitemap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
88 changes: 88 additions & 0 deletions gui/sitemap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down