1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +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/hover = ExtResource( 1 )
custom_styles/pressed = ExtResource( 2 ) custom_styles/pressed = ExtResource( 2 )
custom_styles/normal = ExtResource( 3 ) custom_styles/normal = ExtResource( 3 )
button_mask = 3
icon = SubResource( 1 ) icon = SubResource( 1 )
[node name="NinePatchRect" type="NinePatchRect" parent="."] [node name="NinePatchRect" type="NinePatchRect" parent="."]

View file

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