1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 09:09:47 +00:00

Merge pull request #2 from Orama-Interactive/master

Made color palette buttons work for the right mouse button too
This commit is contained in:
greusser 2019-12-14 22:06:41 -05:00 committed by GitHub
commit a235d06e15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 51 deletions

File diff suppressed because one or more lines are too long

View file

@ -14,6 +14,7 @@ rect_min_size = Vector2( 22, 22 )
custom_styles/hover = ExtResource( 1 )
custom_styles/pressed = ExtResource( 2 )
custom_styles/normal = ExtResource( 3 )
button_mask = 3
icon = SubResource( 1 )
[node name="NinePatchRect" type="NinePatchRect" parent="."]

View file

@ -1,10 +1,6 @@
extends GridContainer
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var palette_button = load("res://Prefabs/PaletteButton.tscn");
var palette_button = preload("res://Prefabs/PaletteButton.tscn");
var default_palette = [
Color("#FF000000"),
@ -42,20 +38,19 @@ var default_palette = [
]
# Called when the node enters the scene tree for the first time.
func _ready():
var index = 0
func _ready() -> void:
var index := 0
for color in default_palette:
var new_button = palette_button.instance()
new_button.get_child(0).modulate = color
new_button.connect("pressed", self, "_on_color_select", [index])
add_child(new_button)
index += 1
pass # Replace with function body.
func _on_color_select(index):
Global.left_color_picker.color = default_palette[index]
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _on_color_select(index : int) -> void:
if Input.is_action_just_released("left_mouse"):
Global.left_color_picker.color = default_palette[index]
Global.update_left_custom_brush()
elif Input.is_action_just_released("right_mouse"):
Global.right_color_picker.color = default_palette[index]
Global.update_right_custom_brush()