Skip to content

Commit 9fd678d

Browse files
authored
Merge pull request #1345 from nibirubingus/verkhov-fixrightclick
Add alternative rightclick behavior overlay to `gui/design`
2 parents c2d1b9e + 0beb896 commit 9fd678d

File tree

3 files changed

+51
-5
lines changed

3 files changed

+51
-5
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Template for new versions:
5151
- `gui/gm-editor`: automatic display of semantic values for language_name fields
5252
- `fix/stuck-worship`: reduced console output by default. Added ``--verbose`` and ``--quiet`` options.
5353
- `necronomicon`: new ``--world`` option to list all secret-containing items in the entire world
54+
- `gui/design`: new ``gui/design.rightclick`` overlay that prevents right click from closing designation mode when drawing boxes and minecart tracks
5455

5556
## Removed
5657
- `modtools/force`: merged into `force`

docs/gui/design.rst

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ gui/design
44

55
.. dfhack-tool::
66
:summary: Design designation utility with shapes.
7-
:tags: fort design productivity map
7+
:tags: fort design productivity interface map
88

99
This tool provides a point and click interface to make designating shapes
1010
and patterns easier. Supports both digging designations and placing constructions.
@@ -19,7 +19,18 @@ Usage
1919
Overlay
2020
-------
2121

22-
This script provides an overlay that shows the selected dimensions when
23-
designating something with vanilla tools, for example when painting a burrow or
24-
designating digging. The dimensions show up in a tooltip that follows the mouse
25-
cursor.
22+
This tool also provides two overlays that are managed by the `overlay` framework.
23+
24+
dimensions
25+
~~~~~~~~~~
26+
27+
The ``gui/design.dimensions`` overlay shows the selected dimensions when designating
28+
with vanilla tools, for example when painting a burrow or designating digging.
29+
The dimensions show up in a tooltip that follows the mouse cursor.
30+
31+
rightclick
32+
~~~~~~~~~~
33+
34+
The ``gui/design.rightclick`` overlay prevents the right mouse button and other keys
35+
bound to "Leave screen" from exiting out of designation mode when drawing a box with
36+
vanilla tools, instead making it cancel the designation first.

gui/design.lua

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,42 @@ function DimensionsOverlay:preUpdateLayout(parent_rect)
120120
self.frame.h = parent_rect.height
121121
end
122122

123+
---
124+
--- RightClickOverlay
125+
---
126+
127+
RightClickOverlay = defclass(RightClickOverlay, overlay.OverlayWidget)
128+
RightClickOverlay.ATTRS{
129+
desc='When drawing boxes, makes right click cancel selection instead of exiting.',
130+
default_enabled=true,
131+
viewscreens={
132+
'dwarfmode/Designate',
133+
'dwarfmode/Burrow/Paint',
134+
'dwarfmode/Stockpile/Paint',
135+
'dwarfmode/Zone/Paint',
136+
'dwarfmode/Building/Placement'
137+
},
138+
}
139+
140+
function RightClickOverlay:onInput(keys)
141+
if keys._MOUSE_R or keys.LEAVESCREEN then
142+
-- building mode
143+
if uibs.selection_pos.x >= 0 then
144+
uibs.selection_pos:clear()
145+
return true
146+
-- all other modes
147+
elseif selection_rect.start_x >= 0 then
148+
selection_rect.start_x = -30000
149+
selection_rect.start_y = -30000
150+
selection_rect.start_z = -30000
151+
return true
152+
end
153+
end
154+
end
155+
123156
OVERLAY_WIDGETS = {
124157
dimensions=DimensionsOverlay,
158+
rightclick=RightClickOverlay,
125159
}
126160

127161
---

0 commit comments

Comments
 (0)