-
Notifications
You must be signed in to change notification settings - Fork 205
Add toolbar button for gui/design
#1425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
realSquidCoder
wants to merge
6
commits into
DFHack:master
Choose a base branch
from
SquidCoderIndustries:squid-design-toolbar
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
236c54e
Add toolbar button for `gui/design`
realSquidCoder a1e8500
Update changelog.txt
realSquidCoder 00a1324
Fix the positioning
realSquidCoder d17b1ca
fix up a non-bug
realSquidCoder 7f0a8d2
Merge branch 'master' into squid-design-toolbar
realSquidCoder 1a101c2
Fix the overlays being overwritten
realSquidCoder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
@@ -168,11 +175,6 @@ function RightClickOverlay:onInput(keys) | |
end | ||
end | ||
|
||
OVERLAY_WIDGETS = { | ||
dimensions=DimensionsOverlay, | ||
rightclick=RightClickOverlay, | ||
} | ||
|
||
--- | ||
--- HelpWindow | ||
--- | ||
|
@@ -1565,6 +1567,94 @@ 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=50, 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_design, | ||
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 | ||
Comment on lines
+1648
to
+1650
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this function is a noop and can be removed |
||
|
||
OVERLAY_WIDGETS = { | ||
dimensions=DimensionsOverlay, | ||
rightclick=RightClickOverlay, | ||
toolbar=DesignToolbarOverlay | ||
} | ||
|
||
if dfhack_flags.module then return end | ||
|
||
if not dfhack.isMapLoaded() then | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This position isn't going to work:

mayyybe here in the dig toolbar?

though that bar is already quite crowded..
another option could be moving the sitemap button over one tile and placing this next to it, but that might also be too crowded. The space next to the sitemap button is there for a reason.