2019-11-30 00:41:34 +02:00
|
|
|
extends BaseButton
|
2019-09-25 22:59:48 +03:00
|
|
|
|
2021-07-21 18:29:52 +03:00
|
|
|
var brush = Global.brushes_popup.Brush.new()
|
2020-05-01 20:47:10 +03:00
|
|
|
|
2024-03-02 19:21:29 +01:00
|
|
|
|
2024-03-02 18:25:00 +01:00
|
|
|
func _ready() -> void:
|
|
|
|
Tools.flip_rotate.connect(_flip_rotate_updated)
|
|
|
|
|
2019-09-25 22:59:48 +03:00
|
|
|
|
|
|
|
func _on_BrushButton_pressed() -> void:
|
2020-01-28 00:19:55 +02:00
|
|
|
# Delete the brush on middle mouse press
|
|
|
|
if Input.is_action_just_released("middle_mouse"):
|
|
|
|
_on_DeleteButton_pressed()
|
2020-06-05 17:21:35 +03:00
|
|
|
else:
|
2020-07-09 20:22:17 +08:00
|
|
|
Global.brushes_popup.select_brush(brush)
|
2019-11-11 15:55:28 +02:00
|
|
|
|
2020-05-01 20:47:10 +03:00
|
|
|
|
2019-11-11 15:55:28 +02:00
|
|
|
func _on_DeleteButton_pressed() -> void:
|
2021-07-21 18:29:52 +03:00
|
|
|
if brush.type != Global.brushes_popup.CUSTOM:
|
2020-06-05 17:21:35 +03:00
|
|
|
return
|
|
|
|
|
2020-07-09 20:22:17 +08:00
|
|
|
Global.brushes_popup.remove_brush(self)
|
2019-11-11 15:55:28 +02:00
|
|
|
|
2020-05-01 20:47:10 +03:00
|
|
|
|
2019-11-11 15:55:28 +02:00
|
|
|
func _on_BrushButton_mouse_entered() -> void:
|
2021-07-21 18:29:52 +03:00
|
|
|
if brush.type == Global.brushes_popup.CUSTOM:
|
2019-11-11 15:55:28 +02:00
|
|
|
$DeleteButton.visible = true
|
|
|
|
|
2020-05-01 20:47:10 +03:00
|
|
|
|
2019-11-11 15:55:28 +02:00
|
|
|
func _on_BrushButton_mouse_exited() -> void:
|
2021-07-21 18:29:52 +03:00
|
|
|
if brush.type == Global.brushes_popup.CUSTOM:
|
2019-11-11 15:55:28 +02:00
|
|
|
$DeleteButton.visible = false
|
2024-03-02 18:25:00 +01:00
|
|
|
|
2024-03-02 19:21:29 +01:00
|
|
|
|
|
|
|
func _flip_rotate_updated(
|
2024-03-02 19:26:59 +01:00
|
|
|
flip_x: bool, flip_y: bool, rotate_90: bool, rotate_180: bool, rotate_270: bool
|
2024-03-02 19:21:29 +01:00
|
|
|
):
|
2024-03-02 18:40:46 +01:00
|
|
|
$BrushTexture.set_flip_h(flip_x)
|
2024-03-02 18:25:00 +01:00
|
|
|
$BrushTexture.set_flip_v(flip_y)
|
2024-03-02 19:42:12 +01:00
|
|
|
var rotation_BrushTexture = 0
|
2024-03-02 19:21:29 +01:00
|
|
|
if rotate_90 == true:
|
2024-03-02 19:42:12 +01:00
|
|
|
rotation_BrushTexture += 90
|
2024-03-02 19:21:29 +01:00
|
|
|
if rotate_180 == true:
|
2024-03-02 19:42:12 +01:00
|
|
|
rotation_BrushTexture += 180
|
2024-03-02 19:21:29 +01:00
|
|
|
if rotate_270 == true:
|
2024-03-02 19:42:12 +01:00
|
|
|
rotation_BrushTexture += 270
|
|
|
|
$BrushTexture.rotation_degrees = rotation_BrushTexture
|