2020-07-09 12:22:17 +00:00
|
|
|
extends "res://src/Tools/Draw.gd"
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
enum ShadingMode { SIMPLE, HUE_SHIFTING }
|
|
|
|
enum LightenDarken { LIGHTEN, DARKEN }
|
2020-11-01 14:00:18 +00:00
|
|
|
|
2021-11-11 01:21:34 +00:00
|
|
|
var _prev_mode := 0
|
2020-07-09 12:22:17 +00:00
|
|
|
var _last_position := Vector2.INF
|
|
|
|
var _changed := false
|
2021-11-25 12:48:30 +00:00
|
|
|
var _shading_mode: int = ShadingMode.SIMPLE
|
|
|
|
var _mode: int = LightenDarken.LIGHTEN
|
2020-07-09 12:22:17 +00:00
|
|
|
var _amount := 10
|
2020-11-01 14:00:18 +00:00
|
|
|
var _hue_amount := 10
|
|
|
|
var _sat_amount := 10
|
|
|
|
var _value_amount := 10
|
2020-07-09 12:22:17 +00:00
|
|
|
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
class LightenDarkenOp:
|
|
|
|
extends Drawer.ColorOp
|
2020-07-09 12:22:17 +00:00
|
|
|
var changed := false
|
2021-11-25 12:48:30 +00:00
|
|
|
var shading_mode: int = ShadingMode.SIMPLE
|
|
|
|
var lighten_or_darken: int = LightenDarken.LIGHTEN
|
2020-11-01 14:00:18 +00:00
|
|
|
var hue_amount := 10.0
|
|
|
|
var sat_amount := 10.0
|
|
|
|
var value_amount := 10.0
|
2020-07-09 12:22:17 +00:00
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
var hue_lighten_limit := 60.0 / 360.0 # A yellow color
|
|
|
|
var hue_darken_limit := 240.0 / 360.0 # A blue color
|
2020-11-17 02:18:36 +00:00
|
|
|
|
|
|
|
var sat_lighten_limit := 10.0 / 100.0
|
|
|
|
var value_darken_limit := 10.0 / 100.0
|
|
|
|
|
2020-07-09 12:22:17 +00:00
|
|
|
func process(_src: Color, dst: Color) -> Color:
|
|
|
|
changed = true
|
2020-11-02 18:07:31 +00:00
|
|
|
if dst.a == 0:
|
|
|
|
return dst
|
2020-11-01 14:00:18 +00:00
|
|
|
if shading_mode == ShadingMode.SIMPLE:
|
2021-11-11 01:21:34 +00:00
|
|
|
if lighten_or_darken == LightenDarken.LIGHTEN:
|
2020-11-01 14:00:18 +00:00
|
|
|
dst = dst.lightened(strength)
|
2021-11-11 01:21:34 +00:00
|
|
|
else:
|
|
|
|
dst = dst.darkened(strength)
|
2020-07-09 12:22:17 +00:00
|
|
|
else:
|
2021-08-23 14:04:52 +00:00
|
|
|
var hue_shift := hue_amount / 360.0
|
2020-11-17 02:18:36 +00:00
|
|
|
var sat_shift := sat_amount / 100.0
|
|
|
|
var value_shift := value_amount / 100.0
|
|
|
|
|
2021-08-23 14:04:52 +00:00
|
|
|
# If the colors are roughly between yellow-green-blue,
|
2020-11-17 02:18:36 +00:00
|
|
|
# reverse hue direction
|
2021-08-23 14:04:52 +00:00
|
|
|
if hue_range(dst.h):
|
2020-11-17 02:18:36 +00:00
|
|
|
hue_shift = -hue_shift
|
|
|
|
|
2020-11-01 14:00:18 +00:00
|
|
|
if lighten_or_darken == LightenDarken.LIGHTEN:
|
2020-11-17 02:18:36 +00:00
|
|
|
hue_shift = hue_limit_lighten(dst.h, hue_shift)
|
2021-08-23 14:04:52 +00:00
|
|
|
dst.h = fposmod(dst.h + hue_shift, 1)
|
2021-08-19 13:49:14 +00:00
|
|
|
if dst.s > sat_lighten_limit:
|
|
|
|
dst.s = max(dst.s - min(sat_shift, dst.s), sat_lighten_limit)
|
2020-11-17 02:18:36 +00:00
|
|
|
dst.v += value_shift
|
|
|
|
|
2020-11-01 14:00:18 +00:00
|
|
|
else:
|
2020-11-17 02:18:36 +00:00
|
|
|
hue_shift = hue_limit_darken(dst.h, hue_shift)
|
2021-08-23 14:04:52 +00:00
|
|
|
dst.h = fposmod(dst.h - hue_shift, 1)
|
2020-11-17 02:18:36 +00:00
|
|
|
dst.s += sat_shift
|
2021-08-19 13:49:14 +00:00
|
|
|
if dst.v > value_darken_limit:
|
|
|
|
dst.v = max(dst.v - min(value_shift, dst.v), value_darken_limit)
|
2020-11-01 14:00:18 +00:00
|
|
|
|
|
|
|
return dst
|
2020-07-09 12:22:17 +00:00
|
|
|
|
2021-08-23 14:04:52 +00:00
|
|
|
# Returns true if the colors are roughly between yellow, green and blue
|
|
|
|
# False when the colors are roughly between red-orange-yellow, or blue-purple-red
|
2021-11-25 12:48:30 +00:00
|
|
|
func hue_range(hue: float) -> bool:
|
2021-08-23 14:04:52 +00:00
|
|
|
return hue > hue_lighten_limit and hue < hue_darken_limit
|
2020-11-17 02:18:36 +00:00
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
func hue_limit_lighten(hue: float, hue_shift: float) -> float:
|
2021-08-23 14:04:52 +00:00
|
|
|
# Colors between red-orange-yellow and blue-purple-red
|
2020-11-17 02:18:36 +00:00
|
|
|
if hue_shift > 0:
|
2021-08-23 14:04:52 +00:00
|
|
|
# Just colors between red-orange-yellow
|
2020-11-17 02:18:36 +00:00
|
|
|
if hue < hue_darken_limit:
|
|
|
|
if hue + hue_shift >= hue_lighten_limit:
|
2021-08-23 14:04:52 +00:00
|
|
|
hue_shift = hue_lighten_limit - hue
|
|
|
|
# Just blue-purple-red
|
|
|
|
else:
|
2021-11-25 12:48:30 +00:00
|
|
|
if hue + hue_shift >= hue_lighten_limit + 1: # +1 looping around the color wheel
|
2021-08-23 14:04:52 +00:00
|
|
|
hue_shift = hue_lighten_limit - hue
|
2020-11-17 02:18:36 +00:00
|
|
|
|
2021-08-23 14:04:52 +00:00
|
|
|
# Colors between yellow-green-blue
|
2020-11-17 02:18:36 +00:00
|
|
|
elif hue_shift < 0 and hue + hue_shift <= hue_lighten_limit:
|
2021-08-23 14:04:52 +00:00
|
|
|
hue_shift = hue_lighten_limit - hue
|
2020-11-17 02:18:36 +00:00
|
|
|
return hue_shift
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
func hue_limit_darken(hue: float, hue_shift: float) -> float:
|
2021-08-23 14:04:52 +00:00
|
|
|
# Colors between red-orange-yellow and blue-purple-red
|
2020-11-17 02:18:36 +00:00
|
|
|
if hue_shift > 0:
|
2021-08-23 14:04:52 +00:00
|
|
|
# Just colors between red-orange-yellow
|
|
|
|
if hue < hue_darken_limit:
|
2021-11-25 12:48:30 +00:00
|
|
|
if hue - hue_shift <= hue_darken_limit - 1: # -1 looping backwards around the color wheel
|
2021-08-23 14:04:52 +00:00
|
|
|
hue_shift = hue - hue_darken_limit
|
|
|
|
# Just blue-purple-red
|
|
|
|
else:
|
|
|
|
if hue - hue_shift <= hue_darken_limit:
|
|
|
|
hue_shift = hue - hue_darken_limit
|
2020-11-17 02:18:36 +00:00
|
|
|
|
2021-08-23 14:04:52 +00:00
|
|
|
# Colors between yellow-green-blue
|
2021-08-18 18:53:42 +00:00
|
|
|
elif hue_shift < 0 and hue - hue_shift >= hue_darken_limit:
|
2021-08-23 14:04:52 +00:00
|
|
|
hue_shift = hue - hue_darken_limit
|
2020-11-17 02:18:36 +00:00
|
|
|
return hue_shift
|
|
|
|
|
|
|
|
|
2020-07-09 12:22:17 +00:00
|
|
|
func _init() -> void:
|
|
|
|
_drawer.color_op = LightenDarkenOp.new()
|
|
|
|
|
|
|
|
|
2021-11-11 01:21:34 +00:00
|
|
|
func _input(event: InputEvent) -> void:
|
2021-11-25 12:48:30 +00:00
|
|
|
var options: OptionButton = $LightenDarken
|
2021-11-11 01:21:34 +00:00
|
|
|
|
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 12:07:51 +00:00
|
|
|
if event.is_action_pressed("change_tool_mode"):
|
2021-11-11 01:21:34 +00:00
|
|
|
_prev_mode = options.selected
|
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 12:07:51 +00:00
|
|
|
if event.is_action("change_tool_mode"):
|
2021-11-11 01:21:34 +00:00
|
|
|
options.selected = _prev_mode ^ 1
|
|
|
|
_mode = options.selected
|
|
|
|
_drawer.color_op.lighten_or_darken = _mode
|
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 12:07:51 +00:00
|
|
|
if event.is_action_released("change_tool_mode"):
|
2021-11-11 01:21:34 +00:00
|
|
|
options.selected = _prev_mode
|
|
|
|
_mode = options.selected
|
|
|
|
_drawer.color_op.lighten_or_darken = _mode
|
|
|
|
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
func _on_ShadingMode_item_selected(id: int) -> void:
|
2020-11-01 14:00:18 +00:00
|
|
|
_shading_mode = id
|
|
|
|
_drawer.color_op.shading_mode = id
|
|
|
|
update_config()
|
|
|
|
save_config()
|
|
|
|
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
func _on_LightenDarken_item_selected(id: int) -> void:
|
2020-07-09 12:22:17 +00:00
|
|
|
_mode = id
|
2020-11-01 14:00:18 +00:00
|
|
|
_drawer.color_op.lighten_or_darken = id
|
2020-07-09 12:22:17 +00:00
|
|
|
update_config()
|
|
|
|
save_config()
|
|
|
|
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
func _on_LightenDarken_value_changed(value: float) -> void:
|
2020-07-09 12:22:17 +00:00
|
|
|
_amount = int(value)
|
|
|
|
update_config()
|
|
|
|
save_config()
|
|
|
|
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
func _on_LightenDarken_hue_value_changed(value: float) -> void:
|
2020-11-01 14:00:18 +00:00
|
|
|
_hue_amount = int(value)
|
|
|
|
update_config()
|
|
|
|
save_config()
|
|
|
|
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
func _on_LightenDarken_sat_value_changed(value: float) -> void:
|
2020-11-01 14:00:18 +00:00
|
|
|
_sat_amount = int(value)
|
|
|
|
update_config()
|
|
|
|
save_config()
|
|
|
|
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
func _on_LightenDarken_value_value_changed(value: float) -> void:
|
2020-11-01 14:00:18 +00:00
|
|
|
_value_amount = int(value)
|
|
|
|
update_config()
|
|
|
|
save_config()
|
|
|
|
|
|
|
|
|
2020-07-09 12:22:17 +00:00
|
|
|
func get_config() -> Dictionary:
|
|
|
|
var config := .get_config()
|
2020-11-01 14:00:18 +00:00
|
|
|
config["shading_mode"] = _shading_mode
|
2020-07-09 12:22:17 +00:00
|
|
|
config["mode"] = _mode
|
|
|
|
config["amount"] = _amount
|
2020-11-01 14:00:18 +00:00
|
|
|
config["hue_amount"] = _hue_amount
|
|
|
|
config["sat_amount"] = _sat_amount
|
|
|
|
config["value_amount"] = _value_amount
|
2020-07-09 12:22:17 +00:00
|
|
|
return config
|
|
|
|
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
func set_config(config: Dictionary) -> void:
|
2020-07-09 12:22:17 +00:00
|
|
|
.set_config(config)
|
2020-11-01 14:00:18 +00:00
|
|
|
_shading_mode = config.get("shading_mode", _shading_mode)
|
2020-11-02 22:43:48 +00:00
|
|
|
_drawer.color_op.shading_mode = _shading_mode
|
2020-07-09 12:22:17 +00:00
|
|
|
_mode = config.get("mode", _mode)
|
2020-11-02 22:43:48 +00:00
|
|
|
_drawer.color_op.lighten_or_darken = _mode
|
2020-07-09 12:22:17 +00:00
|
|
|
_amount = config.get("amount", _amount)
|
2020-11-01 14:00:18 +00:00
|
|
|
_hue_amount = config.get("hue_amount", _hue_amount)
|
|
|
|
_sat_amount = config.get("sat_amount", _sat_amount)
|
|
|
|
_value_amount = config.get("value_amount", _value_amount)
|
2020-07-09 12:22:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
func update_config() -> void:
|
|
|
|
.update_config()
|
2020-11-01 14:00:18 +00:00
|
|
|
$ShadingMode.selected = _shading_mode
|
2020-07-09 12:22:17 +00:00
|
|
|
$LightenDarken.selected = _mode
|
2022-10-04 21:42:01 +00:00
|
|
|
$AmountSlider.value = _amount
|
|
|
|
$HueShiftingOptions/HueSlider.value = _hue_amount
|
|
|
|
$HueShiftingOptions/SatSlider.value = _sat_amount
|
|
|
|
$HueShiftingOptions/ValueSlider.value = _value_amount
|
|
|
|
$AmountSlider.visible = _shading_mode == ShadingMode.SIMPLE
|
2020-11-01 14:00:18 +00:00
|
|
|
$HueShiftingOptions.visible = _shading_mode == ShadingMode.HUE_SHIFTING
|
2020-07-09 12:22:17 +00:00
|
|
|
update_strength()
|
|
|
|
|
|
|
|
|
|
|
|
func update_strength() -> void:
|
2021-11-11 01:21:34 +00:00
|
|
|
_strength = _amount / 100.0
|
2020-07-09 12:22:17 +00:00
|
|
|
|
2020-11-01 14:00:18 +00:00
|
|
|
_drawer.color_op.hue_amount = _hue_amount
|
|
|
|
_drawer.color_op.sat_amount = _sat_amount
|
|
|
|
_drawer.color_op.value_amount = _value_amount
|
|
|
|
|
2020-07-09 12:22:17 +00:00
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
func draw_start(position: Vector2) -> void:
|
2023-01-25 02:37:03 +00:00
|
|
|
position = snap_position(position)
|
2021-12-14 23:39:24 +00: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 12:07:51 +00:00
|
|
|
if Input.is_action_pressed("draw_color_picker"):
|
2021-11-14 01:30:00 +00:00
|
|
|
_picking_color = true
|
|
|
|
_pick_color(position)
|
|
|
|
return
|
|
|
|
_picking_color = false
|
|
|
|
|
2021-04-23 20:37:07 +00:00
|
|
|
Global.canvas.selection.transform_content_confirm()
|
2021-04-16 18:47:03 +00:00
|
|
|
update_mask(false)
|
2020-07-09 12:22:17 +00:00
|
|
|
_changed = false
|
|
|
|
_drawer.color_op.changed = false
|
|
|
|
|
2021-12-06 16:38:54 +00:00
|
|
|
prepare_undo("Draw")
|
2020-07-09 12:22:17 +00:00
|
|
|
_drawer.reset()
|
|
|
|
|
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 12:07:51 +00:00
|
|
|
_draw_line = Input.is_action_pressed("draw_create_line")
|
2020-07-09 12:22:17 +00:00
|
|
|
if _draw_line:
|
2023-05-18 10:55:08 +00:00
|
|
|
if Global.mirror_view:
|
|
|
|
# mirroring position is ONLY required by "Preview"
|
|
|
|
position.x = (Global.current_project.size.x - 1) - position.x
|
2020-07-09 12:22:17 +00:00
|
|
|
_line_start = position
|
|
|
|
_line_end = position
|
|
|
|
update_line_polylines(_line_start, _line_end)
|
|
|
|
else:
|
|
|
|
draw_tool(position)
|
|
|
|
_last_position = position
|
|
|
|
Global.canvas.sprite_changed_this_frame = true
|
|
|
|
cursor_text = ""
|
|
|
|
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
func draw_move(position: Vector2) -> void:
|
2023-01-25 02:37:03 +00:00
|
|
|
position = snap_position(position)
|
2021-12-14 23:39:24 +00:00
|
|
|
.draw_move(position)
|
2021-11-25 12:48:30 +00: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 12:07:51 +00:00
|
|
|
if Input.is_action_pressed("draw_color_picker"):
|
2021-11-14 01:30:00 +00:00
|
|
|
_pick_color(position)
|
|
|
|
return
|
|
|
|
|
2020-07-09 12:22:17 +00:00
|
|
|
if _draw_line:
|
2023-05-18 10:55:08 +00:00
|
|
|
if Global.mirror_view:
|
|
|
|
# mirroring position is ONLY required by "Preview"
|
|
|
|
position.x = (Global.current_project.size.x - 1) - position.x
|
2023-01-25 02:37:03 +00:00
|
|
|
var d := _line_angle_constraint(_line_start, position)
|
2020-07-09 12:22:17 +00:00
|
|
|
_line_end = d.position
|
|
|
|
cursor_text = d.text
|
|
|
|
update_line_polylines(_line_start, _line_end)
|
|
|
|
else:
|
|
|
|
draw_fill_gap(_last_position, position)
|
|
|
|
_last_position = position
|
|
|
|
cursor_text = ""
|
|
|
|
Global.canvas.sprite_changed_this_frame = true
|
|
|
|
|
|
|
|
|
2021-12-14 23:39:24 +00:00
|
|
|
func draw_end(position: Vector2) -> void:
|
2023-01-25 02:37:03 +00:00
|
|
|
position = snap_position(position)
|
2021-12-14 23:39:24 +00:00
|
|
|
.draw_end(position)
|
2021-11-14 01:30:00 +00:00
|
|
|
if _picking_color:
|
|
|
|
return
|
|
|
|
|
2020-07-09 12:22:17 +00:00
|
|
|
if _draw_line:
|
2023-05-18 10:55:08 +00:00
|
|
|
if Global.mirror_view:
|
|
|
|
# now we revert back the coordinates from their mirror form so that line can be drawn
|
|
|
|
_line_start.x = (Global.current_project.size.x - 1) - _line_start.x
|
|
|
|
_line_end.x = (Global.current_project.size.x - 1) - _line_end.x
|
2020-07-09 12:22:17 +00:00
|
|
|
draw_tool(_line_start)
|
|
|
|
draw_fill_gap(_line_start, _line_end)
|
|
|
|
_draw_line = false
|
2021-12-25 17:21:09 +00:00
|
|
|
|
|
|
|
commit_undo()
|
2020-07-09 12:22:17 +00:00
|
|
|
cursor_text = ""
|
|
|
|
update_random_image()
|
|
|
|
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
func _draw_brush_image(image: Image, src_rect: Rect2, dst: Vector2) -> void:
|
2020-07-09 12:22:17 +00:00
|
|
|
_changed = true
|
2021-07-20 23:19:46 +00:00
|
|
|
image.lock()
|
|
|
|
for xx in image.get_size().x:
|
|
|
|
for yy in image.get_size().y:
|
|
|
|
if image.get_pixel(xx, yy).a > 0:
|
|
|
|
var pos := Vector2(xx, yy) + dst - src_rect.position
|
|
|
|
_set_pixel(pos, true)
|
|
|
|
image.unlock()
|
2021-10-15 12:49:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
func update_brush() -> void:
|
|
|
|
.update_brush()
|
|
|
|
$ColorInterpolation.visible = false
|