2021-03-30 14:07:13 -03:00
|
|
|
extends "res://src/Tools/Draw.gd"
|
|
|
|
|
|
|
|
var _start := Vector2.ZERO
|
2021-05-03 03:11:12 +03:00
|
|
|
var _offset := Vector2.ZERO
|
2021-03-30 14:07:13 -03:00
|
|
|
var _dest := Vector2.ZERO
|
|
|
|
var _fill := false
|
|
|
|
var _drawing := false
|
2021-05-03 03:11:12 +03:00
|
|
|
var _displace_origin := false
|
2021-03-30 14:07:13 -03:00
|
|
|
var _thickness := 1
|
|
|
|
|
|
|
|
|
|
|
|
func _init() -> void:
|
|
|
|
_drawer.color_op = Drawer.ColorOp.new()
|
2021-07-08 21:48:47 +03:00
|
|
|
update_indicator()
|
|
|
|
|
|
|
|
|
|
|
|
func update_brush() -> void:
|
|
|
|
pass
|
2021-03-30 14:07:13 -03:00
|
|
|
|
|
|
|
|
|
|
|
func _on_Thickness_value_changed(value: int) -> void:
|
|
|
|
_thickness = value
|
2021-07-08 21:48:47 +03:00
|
|
|
|
|
|
|
update_indicator()
|
2021-03-30 14:07:13 -03:00
|
|
|
update_config()
|
|
|
|
save_config()
|
|
|
|
|
|
|
|
|
2021-07-08 21:48:47 +03:00
|
|
|
func update_indicator() -> void:
|
2021-07-08 22:26:32 +03:00
|
|
|
var indicator := BitMap.new()
|
|
|
|
var rect := _get_result_rect(_start, _dest)
|
|
|
|
var points := _get_points(rect.size)
|
|
|
|
var t_offset := _thickness - 1
|
|
|
|
var t_offsetv := Vector2(t_offset, t_offset)
|
|
|
|
indicator.create(rect.size + t_offsetv * 2)
|
|
|
|
for point in points:
|
|
|
|
indicator.set_bit(point, 1)
|
|
|
|
|
|
|
|
_indicator = indicator
|
2021-07-08 21:48:47 +03:00
|
|
|
_polylines = _create_polylines(_indicator)
|
|
|
|
|
|
|
|
|
2021-03-30 14:07:13 -03:00
|
|
|
func _on_FillCheckbox_toggled(button_pressed: bool) -> void:
|
|
|
|
_fill = button_pressed
|
|
|
|
update_config()
|
|
|
|
save_config()
|
|
|
|
|
|
|
|
|
|
|
|
func get_config() -> Dictionary:
|
|
|
|
var config := .get_config()
|
|
|
|
config["fill"] = _fill
|
|
|
|
config["thickness"] = _thickness
|
|
|
|
return config
|
|
|
|
|
|
|
|
|
|
|
|
func set_config(config: Dictionary) -> void:
|
|
|
|
.set_config(config)
|
|
|
|
_fill = config.get("fill", _fill)
|
|
|
|
_thickness = config.get("thickness", _thickness)
|
|
|
|
|
|
|
|
|
|
|
|
func update_config() -> void:
|
|
|
|
.update_config()
|
|
|
|
$FillCheckbox.pressed = _fill
|
|
|
|
$ThicknessSlider.value = _thickness
|
|
|
|
$ShapeThickness/ThicknessSpinbox.value = _thickness
|
|
|
|
|
|
|
|
|
|
|
|
func _get_shape_points(_size: Vector2) -> PoolVector2Array:
|
|
|
|
return PoolVector2Array()
|
|
|
|
|
|
|
|
|
|
|
|
func _get_shape_points_filled(_size: Vector2) -> PoolVector2Array:
|
|
|
|
return PoolVector2Array()
|
|
|
|
|
|
|
|
|
2021-11-25 14:48:30 +02:00
|
|
|
func _input(event: InputEvent) -> void:
|
2021-05-03 03:11:12 +03:00
|
|
|
if _drawing:
|
Implement the Keychain Plugin (#700)
* Start implementing the godot_better_input plugin
* Update ShortcutEdit.gd
* Load & save preset option
* Add some groups and fix action events not being deleted on load
* Add MenuInputAction class for multiple menu accelerators
* Create a proper plugin and a BetterInput autoload
* Update menu accelerators
* Move settings to BetterInput
* Move menu enums to Global, make more MenuInputActions
* Add more menu events
* Add new groups
* Optimize BetterInput _input() method
* Remove a lot of lines of code
* Change some previous events, add ignore actions and a View menu group
* Change update_item_accelerator to update_ui
* Move MenuInputAction initialization to BetterInput.gd
* Update hint tooltips when a shortcut changes
Temporarily comment out some code regarding the configurable modifiers
* Some MenuInputAction variable name changes
* Add handle_input() to InputAction
* Update the shortcuts of buttons
* Fix shortcut selector menu position
* Change plugin name into Keychain
* Fix keyboard input dialog exiting when Enter or Space is being pressed
* Add two more groups
* Make groups folded by default
* Temporarily make tool modifier shortcuts not configurable
A temporary change, they will be made configurable again, with different actions that are currently mapped to the same events, local/independent from each other.
* Add license for Keychain
* Fix issue where a key event would be added in other input types
* Fix bug where the assigned state was not updated when the dialog appeared again
* Update Main.tscn
* Add a disabled line edit in keyboard shortcut selector to grab focus
* Load presets in the Keychain autoload
This way, the input actions get updated from the start, instead of only at the ShortcutEdit scene.
WARNING, this currently causes crashes if the menu items have no shortcut binded to them.
* Move custom settings away from Keychain.gd
To keep it the same as the upstream plugin
* Change menu enum names
* Made action_get_first_key() more general
* Use arrays for menu items instead of dictionaries, fixes crash
* Move moveable panels to Window menu
* Format
* Optimize hint tooltip updating
* Add support for translations in Keychain
* Translation changes
* Made tool modifiers configurable
Needs more testing.
* Made camera arrow key movement configurable & joypad axis support
This commit removes the ability to press Shift and Control+Shift to adjust the camera arrow key movement speed. Instead, the speed depends on the zoom level.
The right joypad analog stick is configured to move the camera by default.
* Rename presets into shortcut profiles, use Resources and let users create their own
* [skip ci] Update addons README
* Update Global.gd
2022-05-16 15:07:51 +03:00
|
|
|
if event.is_action_pressed("shape_displace"):
|
2021-05-03 03:11:12 +03:00
|
|
|
_displace_origin = true
|
Implement the Keychain Plugin (#700)
* Start implementing the godot_better_input plugin
* Update ShortcutEdit.gd
* Load & save preset option
* Add some groups and fix action events not being deleted on load
* Add MenuInputAction class for multiple menu accelerators
* Create a proper plugin and a BetterInput autoload
* Update menu accelerators
* Move settings to BetterInput
* Move menu enums to Global, make more MenuInputActions
* Add more menu events
* Add new groups
* Optimize BetterInput _input() method
* Remove a lot of lines of code
* Change some previous events, add ignore actions and a View menu group
* Change update_item_accelerator to update_ui
* Move MenuInputAction initialization to BetterInput.gd
* Update hint tooltips when a shortcut changes
Temporarily comment out some code regarding the configurable modifiers
* Some MenuInputAction variable name changes
* Add handle_input() to InputAction
* Update the shortcuts of buttons
* Fix shortcut selector menu position
* Change plugin name into Keychain
* Fix keyboard input dialog exiting when Enter or Space is being pressed
* Add two more groups
* Make groups folded by default
* Temporarily make tool modifier shortcuts not configurable
A temporary change, they will be made configurable again, with different actions that are currently mapped to the same events, local/independent from each other.
* Add license for Keychain
* Fix issue where a key event would be added in other input types
* Fix bug where the assigned state was not updated when the dialog appeared again
* Update Main.tscn
* Add a disabled line edit in keyboard shortcut selector to grab focus
* Load presets in the Keychain autoload
This way, the input actions get updated from the start, instead of only at the ShortcutEdit scene.
WARNING, this currently causes crashes if the menu items have no shortcut binded to them.
* Move custom settings away from Keychain.gd
To keep it the same as the upstream plugin
* Change menu enum names
* Made action_get_first_key() more general
* Use arrays for menu items instead of dictionaries, fixes crash
* Move moveable panels to Window menu
* Format
* Optimize hint tooltip updating
* Add support for translations in Keychain
* Translation changes
* Made tool modifiers configurable
Needs more testing.
* Made camera arrow key movement configurable & joypad axis support
This commit removes the ability to press Shift and Control+Shift to adjust the camera arrow key movement speed. Instead, the speed depends on the zoom level.
The right joypad analog stick is configured to move the camera by default.
* Rename presets into shortcut profiles, use Resources and let users create their own
* [skip ci] Update addons README
* Update Global.gd
2022-05-16 15:07:51 +03:00
|
|
|
elif event.is_action_released("shape_displace"):
|
2021-05-03 03:11:12 +03:00
|
|
|
_displace_origin = false
|
|
|
|
|
|
|
|
|
2021-11-25 14:48:30 +02:00
|
|
|
func draw_start(position: Vector2) -> void:
|
2021-12-15 01:39:24 +02:00
|
|
|
.draw_start(position)
|
Implement the Keychain Plugin (#700)
* Start implementing the godot_better_input plugin
* Update ShortcutEdit.gd
* Load & save preset option
* Add some groups and fix action events not being deleted on load
* Add MenuInputAction class for multiple menu accelerators
* Create a proper plugin and a BetterInput autoload
* Update menu accelerators
* Move settings to BetterInput
* Move menu enums to Global, make more MenuInputActions
* Add more menu events
* Add new groups
* Optimize BetterInput _input() method
* Remove a lot of lines of code
* Change some previous events, add ignore actions and a View menu group
* Change update_item_accelerator to update_ui
* Move MenuInputAction initialization to BetterInput.gd
* Update hint tooltips when a shortcut changes
Temporarily comment out some code regarding the configurable modifiers
* Some MenuInputAction variable name changes
* Add handle_input() to InputAction
* Update the shortcuts of buttons
* Fix shortcut selector menu position
* Change plugin name into Keychain
* Fix keyboard input dialog exiting when Enter or Space is being pressed
* Add two more groups
* Make groups folded by default
* Temporarily make tool modifier shortcuts not configurable
A temporary change, they will be made configurable again, with different actions that are currently mapped to the same events, local/independent from each other.
* Add license for Keychain
* Fix issue where a key event would be added in other input types
* Fix bug where the assigned state was not updated when the dialog appeared again
* Update Main.tscn
* Add a disabled line edit in keyboard shortcut selector to grab focus
* Load presets in the Keychain autoload
This way, the input actions get updated from the start, instead of only at the ShortcutEdit scene.
WARNING, this currently causes crashes if the menu items have no shortcut binded to them.
* Move custom settings away from Keychain.gd
To keep it the same as the upstream plugin
* Change menu enum names
* Made action_get_first_key() more general
* Use arrays for menu items instead of dictionaries, fixes crash
* Move moveable panels to Window menu
* Format
* Optimize hint tooltip updating
* Add support for translations in Keychain
* Translation changes
* Made tool modifiers configurable
Needs more testing.
* Made camera arrow key movement configurable & joypad axis support
This commit removes the ability to press Shift and Control+Shift to adjust the camera arrow key movement speed. Instead, the speed depends on the zoom level.
The right joypad analog stick is configured to move the camera by default.
* Rename presets into shortcut profiles, use Resources and let users create their own
* [skip ci] Update addons README
* Update Global.gd
2022-05-16 15:07:51 +03:00
|
|
|
if Input.is_action_pressed("shape_displace"):
|
2021-11-14 03:30:00 +02:00
|
|
|
_picking_color = true
|
|
|
|
_pick_color(position)
|
|
|
|
return
|
|
|
|
_picking_color = false
|
|
|
|
|
2021-04-23 23:37:07 +03:00
|
|
|
Global.canvas.selection.transform_content_confirm()
|
2021-03-30 14:07:13 -03:00
|
|
|
update_mask()
|
|
|
|
|
|
|
|
_start = position
|
2021-05-03 03:11:12 +03:00
|
|
|
_offset = position
|
2021-03-30 14:07:13 -03:00
|
|
|
_dest = position
|
|
|
|
_drawing = true
|
|
|
|
|
|
|
|
|
2021-11-25 14:48:30 +02:00
|
|
|
func draw_move(position: Vector2) -> void:
|
2021-12-15 01:39:24 +02:00
|
|
|
.draw_move(position)
|
2021-11-25 14:48:30 +02:00
|
|
|
if _picking_color: # Still return even if we released Alt
|
Implement the Keychain Plugin (#700)
* Start implementing the godot_better_input plugin
* Update ShortcutEdit.gd
* Load & save preset option
* Add some groups and fix action events not being deleted on load
* Add MenuInputAction class for multiple menu accelerators
* Create a proper plugin and a BetterInput autoload
* Update menu accelerators
* Move settings to BetterInput
* Move menu enums to Global, make more MenuInputActions
* Add more menu events
* Add new groups
* Optimize BetterInput _input() method
* Remove a lot of lines of code
* Change some previous events, add ignore actions and a View menu group
* Change update_item_accelerator to update_ui
* Move MenuInputAction initialization to BetterInput.gd
* Update hint tooltips when a shortcut changes
Temporarily comment out some code regarding the configurable modifiers
* Some MenuInputAction variable name changes
* Add handle_input() to InputAction
* Update the shortcuts of buttons
* Fix shortcut selector menu position
* Change plugin name into Keychain
* Fix keyboard input dialog exiting when Enter or Space is being pressed
* Add two more groups
* Make groups folded by default
* Temporarily make tool modifier shortcuts not configurable
A temporary change, they will be made configurable again, with different actions that are currently mapped to the same events, local/independent from each other.
* Add license for Keychain
* Fix issue where a key event would be added in other input types
* Fix bug where the assigned state was not updated when the dialog appeared again
* Update Main.tscn
* Add a disabled line edit in keyboard shortcut selector to grab focus
* Load presets in the Keychain autoload
This way, the input actions get updated from the start, instead of only at the ShortcutEdit scene.
WARNING, this currently causes crashes if the menu items have no shortcut binded to them.
* Move custom settings away from Keychain.gd
To keep it the same as the upstream plugin
* Change menu enum names
* Made action_get_first_key() more general
* Use arrays for menu items instead of dictionaries, fixes crash
* Move moveable panels to Window menu
* Format
* Optimize hint tooltip updating
* Add support for translations in Keychain
* Translation changes
* Made tool modifiers configurable
Needs more testing.
* Made camera arrow key movement configurable & joypad axis support
This commit removes the ability to press Shift and Control+Shift to adjust the camera arrow key movement speed. Instead, the speed depends on the zoom level.
The right joypad analog stick is configured to move the camera by default.
* Rename presets into shortcut profiles, use Resources and let users create their own
* [skip ci] Update addons README
* Update Global.gd
2022-05-16 15:07:51 +03:00
|
|
|
if Input.is_action_pressed("shape_displace"):
|
2021-11-14 03:30:00 +02:00
|
|
|
_pick_color(position)
|
|
|
|
return
|
|
|
|
|
2021-03-30 14:07:13 -03:00
|
|
|
if _drawing:
|
2021-05-03 03:11:12 +03:00
|
|
|
if _displace_origin:
|
|
|
|
_start += position - _offset
|
2021-03-30 14:07:13 -03:00
|
|
|
_dest = position
|
2021-05-03 03:11:12 +03:00
|
|
|
_offset = position
|
2021-07-18 14:28:33 +03:00
|
|
|
_set_cursor_text(_get_result_rect(_start, position))
|
2021-03-30 14:07:13 -03:00
|
|
|
|
|
|
|
|
2021-11-25 14:48:30 +02:00
|
|
|
func draw_end(position: Vector2) -> void:
|
2021-12-15 01:39:24 +02:00
|
|
|
.draw_end(position)
|
2021-11-14 03:30:00 +02:00
|
|
|
if _picking_color:
|
|
|
|
return
|
|
|
|
|
2021-03-30 14:07:13 -03:00
|
|
|
if _drawing:
|
|
|
|
_draw_shape(_start, position)
|
|
|
|
|
|
|
|
_start = Vector2.ZERO
|
|
|
|
_dest = Vector2.ZERO
|
|
|
|
_drawing = false
|
2021-05-03 03:11:12 +03:00
|
|
|
_displace_origin = false
|
2021-07-21 00:45:57 +03:00
|
|
|
cursor_text = ""
|
2021-03-30 14:07:13 -03:00
|
|
|
|
|
|
|
|
|
|
|
func draw_preview() -> void:
|
|
|
|
if _drawing:
|
2021-11-25 14:48:30 +02:00
|
|
|
var canvas: CanvasItem = Global.canvas.previews
|
2021-03-30 14:07:13 -03:00
|
|
|
var indicator := BitMap.new()
|
|
|
|
var rect := _get_result_rect(_start, _dest)
|
|
|
|
var points := _get_points(rect.size)
|
|
|
|
var t_offset := _thickness - 1
|
|
|
|
var t_offsetv := Vector2(t_offset, t_offset)
|
|
|
|
indicator.create(rect.size + t_offsetv * 2)
|
|
|
|
for point in points:
|
|
|
|
indicator.set_bit(point, 1)
|
|
|
|
|
|
|
|
canvas.draw_set_transform(rect.position - t_offsetv, canvas.rotation, canvas.scale)
|
|
|
|
|
|
|
|
for line in _create_polylines(indicator):
|
2021-05-17 02:24:49 +03:00
|
|
|
canvas.draw_polyline(PoolVector2Array(line), Color.black)
|
2021-03-30 14:07:13 -03:00
|
|
|
|
|
|
|
canvas.draw_set_transform(canvas.position, canvas.rotation, canvas.scale)
|
|
|
|
|
|
|
|
|
|
|
|
func _draw_shape(origin: Vector2, dest: Vector2) -> void:
|
|
|
|
var rect := _get_result_rect(origin, dest)
|
|
|
|
var points := _get_points(rect.size)
|
2021-12-07 01:38:54 +09:00
|
|
|
prepare_undo("Draw Shape")
|
2021-03-30 14:07:13 -03:00
|
|
|
for point in points:
|
2021-05-12 04:35:20 +03:00
|
|
|
# Reset drawer every time because pixel perfect sometimes breaks the tool
|
2021-03-30 14:07:13 -03:00
|
|
|
_drawer.reset()
|
|
|
|
# Draw each point offseted based on the shape's thickness
|
|
|
|
draw_tool(rect.position + point - Vector2.ONE * (_thickness - 1))
|
|
|
|
|
2021-12-07 01:38:54 +09:00
|
|
|
commit_undo()
|
2021-03-30 14:07:13 -03:00
|
|
|
|
|
|
|
|
2021-11-25 14:48:30 +02:00
|
|
|
# Given an origin point and destination point, returns a rect representing
|
|
|
|
# where the shape will be drawn and what is its size
|
2021-03-30 14:07:13 -03:00
|
|
|
func _get_result_rect(origin: Vector2, dest: Vector2) -> Rect2:
|
|
|
|
var rect := Rect2(Vector2.ZERO, Vector2.ZERO)
|
|
|
|
|
|
|
|
# Center the rect on the mouse
|
Implement the Keychain Plugin (#700)
* Start implementing the godot_better_input plugin
* Update ShortcutEdit.gd
* Load & save preset option
* Add some groups and fix action events not being deleted on load
* Add MenuInputAction class for multiple menu accelerators
* Create a proper plugin and a BetterInput autoload
* Update menu accelerators
* Move settings to BetterInput
* Move menu enums to Global, make more MenuInputActions
* Add more menu events
* Add new groups
* Optimize BetterInput _input() method
* Remove a lot of lines of code
* Change some previous events, add ignore actions and a View menu group
* Change update_item_accelerator to update_ui
* Move MenuInputAction initialization to BetterInput.gd
* Update hint tooltips when a shortcut changes
Temporarily comment out some code regarding the configurable modifiers
* Some MenuInputAction variable name changes
* Add handle_input() to InputAction
* Update the shortcuts of buttons
* Fix shortcut selector menu position
* Change plugin name into Keychain
* Fix keyboard input dialog exiting when Enter or Space is being pressed
* Add two more groups
* Make groups folded by default
* Temporarily make tool modifier shortcuts not configurable
A temporary change, they will be made configurable again, with different actions that are currently mapped to the same events, local/independent from each other.
* Add license for Keychain
* Fix issue where a key event would be added in other input types
* Fix bug where the assigned state was not updated when the dialog appeared again
* Update Main.tscn
* Add a disabled line edit in keyboard shortcut selector to grab focus
* Load presets in the Keychain autoload
This way, the input actions get updated from the start, instead of only at the ShortcutEdit scene.
WARNING, this currently causes crashes if the menu items have no shortcut binded to them.
* Move custom settings away from Keychain.gd
To keep it the same as the upstream plugin
* Change menu enum names
* Made action_get_first_key() more general
* Use arrays for menu items instead of dictionaries, fixes crash
* Move moveable panels to Window menu
* Format
* Optimize hint tooltip updating
* Add support for translations in Keychain
* Translation changes
* Made tool modifiers configurable
Needs more testing.
* Made camera arrow key movement configurable & joypad axis support
This commit removes the ability to press Shift and Control+Shift to adjust the camera arrow key movement speed. Instead, the speed depends on the zoom level.
The right joypad analog stick is configured to move the camera by default.
* Rename presets into shortcut profiles, use Resources and let users create their own
* [skip ci] Update addons README
* Update Global.gd
2022-05-16 15:07:51 +03:00
|
|
|
if Input.is_action_pressed("shape_center"):
|
2021-03-30 14:07:13 -03:00
|
|
|
var new_size := (dest - origin).floor()
|
|
|
|
# Make rect 1:1 while centering it on the mouse
|
Implement the Keychain Plugin (#700)
* Start implementing the godot_better_input plugin
* Update ShortcutEdit.gd
* Load & save preset option
* Add some groups and fix action events not being deleted on load
* Add MenuInputAction class for multiple menu accelerators
* Create a proper plugin and a BetterInput autoload
* Update menu accelerators
* Move settings to BetterInput
* Move menu enums to Global, make more MenuInputActions
* Add more menu events
* Add new groups
* Optimize BetterInput _input() method
* Remove a lot of lines of code
* Change some previous events, add ignore actions and a View menu group
* Change update_item_accelerator to update_ui
* Move MenuInputAction initialization to BetterInput.gd
* Update hint tooltips when a shortcut changes
Temporarily comment out some code regarding the configurable modifiers
* Some MenuInputAction variable name changes
* Add handle_input() to InputAction
* Update the shortcuts of buttons
* Fix shortcut selector menu position
* Change plugin name into Keychain
* Fix keyboard input dialog exiting when Enter or Space is being pressed
* Add two more groups
* Make groups folded by default
* Temporarily make tool modifier shortcuts not configurable
A temporary change, they will be made configurable again, with different actions that are currently mapped to the same events, local/independent from each other.
* Add license for Keychain
* Fix issue where a key event would be added in other input types
* Fix bug where the assigned state was not updated when the dialog appeared again
* Update Main.tscn
* Add a disabled line edit in keyboard shortcut selector to grab focus
* Load presets in the Keychain autoload
This way, the input actions get updated from the start, instead of only at the ShortcutEdit scene.
WARNING, this currently causes crashes if the menu items have no shortcut binded to them.
* Move custom settings away from Keychain.gd
To keep it the same as the upstream plugin
* Change menu enum names
* Made action_get_first_key() more general
* Use arrays for menu items instead of dictionaries, fixes crash
* Move moveable panels to Window menu
* Format
* Optimize hint tooltip updating
* Add support for translations in Keychain
* Translation changes
* Made tool modifiers configurable
Needs more testing.
* Made camera arrow key movement configurable & joypad axis support
This commit removes the ability to press Shift and Control+Shift to adjust the camera arrow key movement speed. Instead, the speed depends on the zoom level.
The right joypad analog stick is configured to move the camera by default.
* Rename presets into shortcut profiles, use Resources and let users create their own
* [skip ci] Update addons README
* Update Global.gd
2022-05-16 15:07:51 +03:00
|
|
|
if Input.is_action_pressed("shape_perfect"):
|
2021-11-25 14:48:30 +02:00
|
|
|
var square_size := max(abs(new_size.x), abs(new_size.y))
|
|
|
|
new_size = Vector2(square_size, square_size)
|
2021-03-30 14:07:13 -03:00
|
|
|
|
|
|
|
origin -= new_size
|
|
|
|
dest = origin + 2 * new_size
|
|
|
|
|
|
|
|
# Make rect 1:1 while not trying to center it
|
Implement the Keychain Plugin (#700)
* Start implementing the godot_better_input plugin
* Update ShortcutEdit.gd
* Load & save preset option
* Add some groups and fix action events not being deleted on load
* Add MenuInputAction class for multiple menu accelerators
* Create a proper plugin and a BetterInput autoload
* Update menu accelerators
* Move settings to BetterInput
* Move menu enums to Global, make more MenuInputActions
* Add more menu events
* Add new groups
* Optimize BetterInput _input() method
* Remove a lot of lines of code
* Change some previous events, add ignore actions and a View menu group
* Change update_item_accelerator to update_ui
* Move MenuInputAction initialization to BetterInput.gd
* Update hint tooltips when a shortcut changes
Temporarily comment out some code regarding the configurable modifiers
* Some MenuInputAction variable name changes
* Add handle_input() to InputAction
* Update the shortcuts of buttons
* Fix shortcut selector menu position
* Change plugin name into Keychain
* Fix keyboard input dialog exiting when Enter or Space is being pressed
* Add two more groups
* Make groups folded by default
* Temporarily make tool modifier shortcuts not configurable
A temporary change, they will be made configurable again, with different actions that are currently mapped to the same events, local/independent from each other.
* Add license for Keychain
* Fix issue where a key event would be added in other input types
* Fix bug where the assigned state was not updated when the dialog appeared again
* Update Main.tscn
* Add a disabled line edit in keyboard shortcut selector to grab focus
* Load presets in the Keychain autoload
This way, the input actions get updated from the start, instead of only at the ShortcutEdit scene.
WARNING, this currently causes crashes if the menu items have no shortcut binded to them.
* Move custom settings away from Keychain.gd
To keep it the same as the upstream plugin
* Change menu enum names
* Made action_get_first_key() more general
* Use arrays for menu items instead of dictionaries, fixes crash
* Move moveable panels to Window menu
* Format
* Optimize hint tooltip updating
* Add support for translations in Keychain
* Translation changes
* Made tool modifiers configurable
Needs more testing.
* Made camera arrow key movement configurable & joypad axis support
This commit removes the ability to press Shift and Control+Shift to adjust the camera arrow key movement speed. Instead, the speed depends on the zoom level.
The right joypad analog stick is configured to move the camera by default.
* Rename presets into shortcut profiles, use Resources and let users create their own
* [skip ci] Update addons README
* Update Global.gd
2022-05-16 15:07:51 +03:00
|
|
|
if Input.is_action_pressed("shape_perfect"):
|
2021-03-30 14:07:13 -03:00
|
|
|
var square_size := min(abs(origin.x - dest.x), abs(origin.y - dest.y))
|
|
|
|
rect.position.x = origin.x if origin.x < dest.x else origin.x - square_size
|
|
|
|
rect.position.y = origin.y if origin.y < dest.y else origin.y - square_size
|
|
|
|
rect.size = Vector2(square_size, square_size)
|
|
|
|
# Get the rect without any modifications
|
|
|
|
else:
|
|
|
|
rect.position = Vector2(min(origin.x, dest.x), min(origin.y, dest.y))
|
|
|
|
rect.size = (origin - dest).abs()
|
|
|
|
|
|
|
|
rect.size += Vector2.ONE
|
|
|
|
|
|
|
|
return rect
|
|
|
|
|
|
|
|
|
|
|
|
func _get_points(size: Vector2) -> PoolVector2Array:
|
|
|
|
return _get_shape_points_filled(size) if _fill else _get_shape_points(size)
|
|
|
|
|
|
|
|
|
|
|
|
func _outline_point(p: Vector2, thickness: int = 1, include_p: bool = true) -> Array:
|
2021-11-25 14:48:30 +02:00
|
|
|
var array := []
|
2021-03-30 14:07:13 -03:00
|
|
|
|
2021-11-25 14:48:30 +02:00
|
|
|
if thickness != 1:
|
|
|
|
var t_of = thickness - 1
|
|
|
|
for x in range(-t_of, thickness):
|
|
|
|
for y in range(-t_of, thickness):
|
|
|
|
if x == 0 and y == 0 and not include_p:
|
|
|
|
continue
|
|
|
|
array.append(p + Vector2(x, y))
|
|
|
|
return array
|
2021-03-30 14:07:13 -03:00
|
|
|
|
2021-07-18 14:28:33 +03:00
|
|
|
|
2021-11-25 14:48:30 +02:00
|
|
|
func _set_cursor_text(rect: Rect2) -> void:
|
2021-07-18 14:28:33 +03:00
|
|
|
cursor_text = "%s, %s" % [rect.position.x, rect.position.y]
|
|
|
|
cursor_text += " -> %s, %s" % [rect.end.x - 1, rect.end.y - 1]
|
|
|
|
cursor_text += " (%s, %s)" % [rect.size.x, rect.size.y]
|