From 41d80d503a8bd9e9d102dc0cfcff37ca3ebbbfdc Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Fri, 13 Mar 2020 02:04:40 +0200 Subject: [PATCH] Ability to get color for palette buttons, when editing a palette, from the currently selected left and right colors --- Changelog.md | 1 + Main.tscn | 2 +- Prefabs/EditPalettePopup.tscn | 85 +++++++++++++++++++++++++---- Prefabs/PaletteButton.tscn | 6 ++ Scripts/Palette/EditPalettePopup.gd | 15 ++++- 5 files changed, 96 insertions(+), 13 deletions(-) diff --git a/Changelog.md b/Changelog.md index be5451d3e..372aad08b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Importing .pngs as palettes is now possible - thanks to Martin Novák (novhack)! - A confirmation message now appears when the user quits Pixelorama, if there are unsaved changes - thanks to Schweini07! - Locking layers is now possible. When a layer is locked, no changes can be made to it. Layers are unlocked by default. +- Ability to get color for palette buttons, when editing a palette, from the currently selected left and right colors ### Changed - The timeline has been revamped! diff --git a/Main.tscn b/Main.tscn index 6fc13d16e..65e9eb587 100644 --- a/Main.tscn +++ b/Main.tscn @@ -108,6 +108,7 @@ theme = ExtResource( 1 ) script = ExtResource( 2 ) __meta__ = { "_edit_horizontal_guides_": [ ], +"_edit_use_anchors_": false, "_edit_vertical_guides_": [ ] } @@ -1287,7 +1288,6 @@ window_title = "Error!" dialog_text = "This is an error message!" [node name="EditPalettePopup" parent="." instance=ExtResource( 35 )] -visible = false [node name="NewPaletteDialog" parent="." instance=ExtResource( 36 )] diff --git a/Prefabs/EditPalettePopup.tscn b/Prefabs/EditPalettePopup.tscn index 692e6fbde..6b0a2ff93 100644 --- a/Prefabs/EditPalettePopup.tscn +++ b/Prefabs/EditPalettePopup.tscn @@ -1,13 +1,13 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://Scripts/Palette/EditPalettePopup.gd" type="Script" id=1] [ext_resource path="res://Assets/Graphics/Palette/new_swatch_button.png" type="Texture" id=2] [ext_resource path="res://Assets/Graphics/Palette/new_swatch_button_hover.png" type="Texture" id=3] [ext_resource path="res://Assets/Graphics/Palette/remove_swatch_button.png" type="Texture" id=4] [ext_resource path="res://Assets/Graphics/Palette/remove_swatch_button_hover.png" type="Texture" id=5] +[ext_resource path="res://Assets/Graphics/Palette/palette_button_fill.png" type="Texture" id=6] [node name="EditPalettePopup" type="WindowDialog"] -visible = true margin_right = 600.0 margin_bottom = 550.0 rect_min_size = Vector2( 600, 570 ) @@ -30,28 +30,89 @@ margin_bottom = 462.0 size_flags_vertical = 3 [node name="EditPaletteColorPicker" type="ColorPicker" parent="VBoxContainer/HBoxContainer"] -margin_right = 290.0 +margin_right = 308.0 margin_bottom = 462.0 -[node name="Panel" type="Panel" parent="VBoxContainer/HBoxContainer"] -margin_left = 294.0 +[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/HBoxContainer"] +margin_left = 312.0 margin_right = 556.0 margin_bottom = 462.0 size_flags_horizontal = 3 +__meta__ = { +"_edit_use_anchors_": false +} -[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer/HBoxContainer/Panel"] -anchor_right = 1.0 -anchor_bottom = 1.0 +[node name="Panel" type="Panel" parent="VBoxContainer/HBoxContainer/VBoxContainer"] +margin_right = 244.0 +margin_bottom = 408.0 size_flags_horizontal = 3 size_flags_vertical = 3 -[node name="EditPaletteGridContainer" type="GridContainer" parent="VBoxContainer/HBoxContainer/Panel/ScrollContainer"] -margin_right = 262.0 -margin_bottom = 462.0 +[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer/HBoxContainer/VBoxContainer/Panel"] +margin_right = 244.0 +margin_bottom = 438.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="EditPaletteGridContainer" type="GridContainer" parent="VBoxContainer/HBoxContainer/VBoxContainer/Panel/ScrollContainer"] +margin_right = 244.0 +margin_bottom = 438.0 size_flags_horizontal = 3 size_flags_vertical = 3 columns = 8 +[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer/VBoxContainer"] +margin_top = 412.0 +margin_right = 244.0 +margin_bottom = 426.0 +text = "Use current left & right colors" +align = 1 + +[node name="CenterContainer" type="CenterContainer" parent="VBoxContainer/HBoxContainer/VBoxContainer"] +margin_top = 430.0 +margin_right = 244.0 +margin_bottom = 462.0 + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/HBoxContainer/VBoxContainer/CenterContainer"] +margin_left = 56.0 +margin_right = 188.0 +margin_bottom = 32.0 + +[node name="LeftColor" type="Button" parent="VBoxContainer/HBoxContainer/VBoxContainer/CenterContainer/HBoxContainer"] +margin_right = 64.0 +margin_bottom = 32.0 +rect_min_size = Vector2( 64, 32 ) + +[node name="NinePatchRect" type="NinePatchRect" parent="VBoxContainer/HBoxContainer/VBoxContainer/CenterContainer/HBoxContainer/LeftColor"] +modulate = Color( 0, 0, 0, 1 ) +margin_left = 2.0 +margin_top = 3.0 +margin_right = 62.0 +margin_bottom = 29.0 +texture = ExtResource( 6 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="RightColor" type="Button" parent="VBoxContainer/HBoxContainer/VBoxContainer/CenterContainer/HBoxContainer"] +margin_left = 68.0 +margin_right = 132.0 +margin_bottom = 32.0 +rect_min_size = Vector2( 64, 32 ) + +[node name="NinePatchRect" type="NinePatchRect" parent="VBoxContainer/HBoxContainer/VBoxContainer/CenterContainer/HBoxContainer/RightColor"] +margin_left = 2.0 +margin_top = 3.0 +margin_right = 62.0 +margin_bottom = 29.0 +texture = ExtResource( 6 ) +__meta__ = { +"_edit_use_anchors_": false +} + [node name="ColorButtons" type="VBoxContainer" parent="VBoxContainer/HBoxContainer"] margin_left = 560.0 margin_right = 580.0 @@ -136,6 +197,8 @@ margin_right = 580.0 margin_bottom = 20.0 size_flags_horizontal = 3 [connection signal="color_changed" from="VBoxContainer/HBoxContainer/EditPaletteColorPicker" to="." method="_on_EditPaletteColorPicker_color_changed"] +[connection signal="pressed" from="VBoxContainer/HBoxContainer/VBoxContainer/CenterContainer/HBoxContainer/LeftColor" to="." method="_on_LeftColor_pressed"] +[connection signal="pressed" from="VBoxContainer/HBoxContainer/VBoxContainer/CenterContainer/HBoxContainer/RightColor" to="." method="_on_RightColor_pressed"] [connection signal="pressed" from="VBoxContainer/HBoxContainer/ColorButtons/AddSwatchButton" to="." method="_on_AddSwatchButton_pressed"] [connection signal="pressed" from="VBoxContainer/HBoxContainer/ColorButtons/RemoveSwatchButton" to="." method="_on_RemoveSwatchButton_pressed"] [connection signal="text_changed" from="VBoxContainer/PaletteOptions/EditPaletteColorNameLineEdit" to="." method="_on_EditPaletteColorNameLineEdit_text_changed"] diff --git a/Prefabs/PaletteButton.tscn b/Prefabs/PaletteButton.tscn index f009d8e90..08faf5162 100644 --- a/Prefabs/PaletteButton.tscn +++ b/Prefabs/PaletteButton.tscn @@ -22,6 +22,9 @@ action_mode = 0 button_mask = 3 icon = SubResource( 1 ) script = ExtResource( 5 ) +__meta__ = { +"_edit_use_anchors_": false +} [node name="NinePatchRect" type="NinePatchRect" parent="."] anchor_right = 1.0 @@ -37,3 +40,6 @@ patch_margin_left = 2 patch_margin_top = 2 patch_margin_right = 2 patch_margin_bottom = 2 +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/Scripts/Palette/EditPalettePopup.gd b/Scripts/Palette/EditPalettePopup.gd index c6fd4e9e9..13917338c 100644 --- a/Scripts/Palette/EditPalettePopup.gd +++ b/Scripts/Palette/EditPalettePopup.gd @@ -7,9 +7,11 @@ var current_swatch := -1 var working_palette : Palette onready var color_picker = $VBoxContainer/HBoxContainer/EditPaletteColorPicker -onready var palette_grid = $VBoxContainer/HBoxContainer/Panel/ScrollContainer/EditPaletteGridContainer +onready var palette_grid = $VBoxContainer/HBoxContainer/VBoxContainer/Panel/ScrollContainer/EditPaletteGridContainer onready var color_name_edit = $VBoxContainer/PaletteOptions/EditPaletteColorNameLineEdit onready var palette_name_edit = $VBoxContainer/PaletteOptions/EditPaletteNameLineEdit +onready var left_color_button = $VBoxContainer/HBoxContainer/VBoxContainer/CenterContainer/HBoxContainer/LeftColor/NinePatchRect +onready var right_color_button = $VBoxContainer/HBoxContainer/VBoxContainer/CenterContainer/HBoxContainer/RightColor/NinePatchRect func _ready() -> void: $VBoxContainer/HBoxContainer/EditPaletteColorPicker.presets_visible = false @@ -22,6 +24,9 @@ func open(palette : String) -> void: _display_palette() self.popup_centered() + left_color_button.modulate = Global.left_color_picker.color + right_color_button.modulate = Global.right_color_picker.color + func _display_palette() -> void: _clear_swatches() var index := 0 @@ -135,3 +140,11 @@ func _on_EditPaletteColorPicker_color_changed(color : Color) -> void: func _refresh_hint_tooltip(_index : int) -> void: palette_grid.get_child(current_swatch).hint_tooltip = "#" + working_palette.get_color_data(current_swatch).to_upper() + " " + working_palette.get_color_name(current_swatch) + +func _on_LeftColor_pressed() -> void: + color_picker.color = Global.left_color_picker.color + _on_EditPaletteColorPicker_color_changed(color_picker.color) + +func _on_RightColor_pressed() -> void: + color_picker.color = Global.right_color_picker.color + _on_EditPaletteColorPicker_color_changed(color_picker.color)