From 9ba5f6b023d172649319e1730128a95886d049d3 Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Mon, 30 Dec 2019 20:29:46 +0200 Subject: [PATCH] Removed the Remove Palette button Users can now just delete the .json files if they want to remove a palette. --- Changelog.md | 9 +++--- Main.tscn | 48 +++++++++++------------------ Scripts/Global.gd | 6 ++-- Scripts/Main.gd | 7 ++--- Scripts/Palette/PaletteContainer.gd | 24 +-------------- 5 files changed, 28 insertions(+), 66 deletions(-) diff --git a/Changelog.md b/Changelog.md index 8cdb74b04..9d3731e70 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,8 +9,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Palettes. You can choose default ones or make your own! (Thanks to greusser) - Multiple theme support (Dark, Gray, Light, Godot, Gold) to better match your style (Thanks to Erevoid)! - Image sub-menu with new features (Outlines, Color invert, desaturation) for more editing power. -- Added layer opacity feature. -- Added better circle brush and new random brush feature . +- Added a layer opacity slider, that lets you change the alpha values of layers. +- Added a better circle and filled circle brushes. They use Bresenham's circle algorithm to scale. +- Added random brushes! Every time you draw, expect to see something different! To create random brushes, place the images you want your brush to have in the same folder, and put the symbol "%" in front of their filename. Examples, "%icon1.png", "%grass_green.png" - Pixelorama goes worldwide with even more translations! (German, French, Polish, Brazilian Portuguese, Russian, Traditional Chinese) - Importing spritesheets is now possible. - Exporting matrix spritesheets is now possible. You can choose how many rows OR columns your spritesheet will be. @@ -33,13 +34,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Brush color interpolation and LightenDarknen's amount now range from 0-100, instead of 0-1. - Redo has both `Ctrl-Y` and `Shift-Ctrl-Z` as its shortcuts. (Thanks to Schweini07) - Changed positions of color switch & color default buttons. -- Importing brushes from the Brushes older now looks inside its subfolders too, but not the subfolders of the subfolders. +- Importing brushes from the Brushes folder now looks inside its subfolders too, but not the subfolders of the subfolders. +- The Brushes folder now gets created if it doesn't exist (tested on Windows) - Enabled switching between menus in menu bar on hover (Thanks to YeldhamDev) - The "View" menu remains visible when toggling items (Thanks to YeldhamDev) - The UI darkens when exiting the application (Thanks to Calinou) - The bucket tool's "paint all pixels with the same color" now gets limited to the selection, if there is any. - If the alpha on the color picker is at 0 and any of the other RGB values change, alpha becomes 1. (Issue #54) -- The Brushes folder now gets created if it doesn't exist (tested on Windows) ### Fixed - UndoRedo leak (issue #34) (Thanks to qarmin) diff --git a/Main.tscn b/Main.tscn index 9789385c1..9f6ed84fa 100644 --- a/Main.tscn +++ b/Main.tscn @@ -38,14 +38,14 @@ [ext_resource path="res://Assets/Graphics/Dark Themes/Timeline/New_Frame_Hover.png" type="Texture" id=36] [ext_resource path="res://Assets/Graphics/Dark Themes/Palette/Add_Palette.png" type="Texture" id=37] [ext_resource path="res://Assets/Graphics/Dark Themes/Palette/Add_Palette_Hover.png" type="Texture" id=38] -[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Delete_Layer.png" type="Texture" id=39] -[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Delete_Layer_Hover.png" type="Texture" id=40] -[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Delete_Layer_Disabled.png" type="Texture" id=41] -[ext_resource path="res://Assets/Graphics/Dark Themes/Palette/Edit_Palette.png" type="Texture" id=42] -[ext_resource path="res://Assets/Graphics/Dark Themes/Palette/Edit_Palette_Hover.png" type="Texture" id=43] -[ext_resource path="res://Scripts/Palette/PaletteContainer.gd" type="Script" id=44] -[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/New_Layer.png" type="Texture" id=45] -[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/New_Layer_Hover.png" type="Texture" id=46] +[ext_resource path="res://Assets/Graphics/Dark Themes/Palette/Edit_Palette.png" type="Texture" id=39] +[ext_resource path="res://Assets/Graphics/Dark Themes/Palette/Edit_Palette_Hover.png" type="Texture" id=40] +[ext_resource path="res://Scripts/Palette/PaletteContainer.gd" type="Script" id=41] +[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/New_Layer.png" type="Texture" id=42] +[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/New_Layer_Hover.png" type="Texture" id=43] +[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Delete_Layer.png" type="Texture" id=44] +[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Delete_Layer_Hover.png" type="Texture" id=45] +[ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Delete_Layer_Disabled.png" type="Texture" id=46] [ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Move_Up.png" type="Texture" id=47] [ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Move_Up_Hover.png" type="Texture" id=48] [ext_resource path="res://Assets/Graphics/Dark Themes/Layers/Move_Up_Disabled.png" type="Texture" id=49] @@ -1347,8 +1347,8 @@ margin_right = 224.0 margin_bottom = 32.0 [node name="PaletteButtons" type="HBoxContainer" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc/PaletteVBoxContainer/CenterContainer"] -margin_left = 6.0 -margin_right = 217.0 +margin_left = 24.0 +margin_right = 199.0 margin_bottom = 32.0 [node name="AddPalette" type="TextureButton" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc/PaletteVBoxContainer/CenterContainer/PaletteButtons" groups=[ @@ -1365,7 +1365,7 @@ margin_right = 12.0 margin_bottom = 20.0 items = [ "New Empty Palette", null, 0, false, false, 0, 0, null, "", false, "Import Palette", null, 0, false, false, 1, 0, null, "", false ] -[node name="RemovePalette" type="TextureButton" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc/PaletteVBoxContainer/CenterContainer/PaletteButtons" groups=[ +[node name="EditPalette" type="TextureButton" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc/PaletteVBoxContainer/CenterContainer/PaletteButtons" groups=[ "UIButtons", ]] margin_left = 36.0 @@ -1373,7 +1373,6 @@ margin_right = 68.0 margin_bottom = 32.0 texture_normal = ExtResource( 39 ) texture_hover = ExtResource( 40 ) -texture_disabled = ExtResource( 41 ) [node name="PaletteOptionButton" type="OptionButton" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc/PaletteVBoxContainer/CenterContainer/PaletteButtons"] margin_left = 72.0 @@ -1383,15 +1382,6 @@ grow_horizontal = 0 rect_min_size = Vector2( 103, 0 ) clip_text = true -[node name="EditPalette" type="TextureButton" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc/PaletteVBoxContainer/CenterContainer/PaletteButtons" groups=[ -"UIButtons", -]] -margin_left = 179.0 -margin_right = 211.0 -margin_bottom = 32.0 -texture_normal = ExtResource( 42 ) -texture_hover = ExtResource( 43 ) - [node name="ScrollPalette" type="ScrollContainer" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc/PaletteVBoxContainer"] margin_top = 36.0 margin_right = 224.0 @@ -1408,7 +1398,7 @@ margin_left = 112.0 margin_right = 112.0 size_flags_horizontal = 3 columns = 5 -script = ExtResource( 44 ) +script = ExtResource( 41 ) [node name="HSeparator2" type="HSeparator" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc"] margin_top = 359.0 @@ -1454,8 +1444,8 @@ margin_right = 32.0 margin_bottom = 32.0 hint_tooltip = "LAYERNEW_HT" mouse_default_cursor_shape = 2 -texture_normal = ExtResource( 45 ) -texture_hover = ExtResource( 46 ) +texture_normal = ExtResource( 42 ) +texture_hover = ExtResource( 43 ) [node name="RemoveLayer" type="TextureButton" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc/LayerVBoxContainer/CenterLayerButtons/LayerButtons" groups=[ "UIButtons", @@ -1466,9 +1456,9 @@ margin_bottom = 32.0 hint_tooltip = "LAYERREMOVE_HT" mouse_default_cursor_shape = 8 disabled = true -texture_normal = ExtResource( 39 ) -texture_hover = ExtResource( 40 ) -texture_disabled = ExtResource( 41 ) +texture_normal = ExtResource( 44 ) +texture_hover = ExtResource( 45 ) +texture_disabled = ExtResource( 46 ) [node name="MoveUpLayer" type="TextureButton" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc/LayerVBoxContainer/CenterLayerButtons/LayerButtons" groups=[ "UIButtons", @@ -1544,7 +1534,6 @@ margin_bottom = 17.0 rect_min_size = Vector2( 106, 0 ) size_flags_vertical = 1 value = 100.0 -ticks_on_borders = false [node name="OpacitySpinBox" type="SpinBox" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc/LayerVBoxContainer/OpacityCenter/OpacityContainer"] margin_left = 158.0 @@ -1765,9 +1754,8 @@ visible = false [connection signal="value_changed" from="MenuAndUI/UI/CanvasAndTimeline/AnimationTimeline/AnimationContainer/OnionSkinningButtons/FutureOnionSkinning" to="." method="_on_FutureOnionSkinning_value_changed"] [connection signal="toggled" from="MenuAndUI/UI/CanvasAndTimeline/AnimationTimeline/AnimationContainer/OnionSkinningButtons/BlueRedMode" to="." method="_on_BlueRedMode_toggled"] [connection signal="pressed" from="MenuAndUI/UI/LayerPanel/LayersAndMisc/PaletteVBoxContainer/CenterContainer/PaletteButtons/AddPalette" to="." method="_on_AddPalette_pressed"] -[connection signal="pressed" from="MenuAndUI/UI/LayerPanel/LayersAndMisc/PaletteVBoxContainer/CenterContainer/PaletteButtons/RemovePalette" to="." method="_on_RemovePalette_pressed"] -[connection signal="item_selected" from="MenuAndUI/UI/LayerPanel/LayersAndMisc/PaletteVBoxContainer/CenterContainer/PaletteButtons/PaletteOptionButton" to="." method="_on_PaletteOptionButton_item_selected"] [connection signal="pressed" from="MenuAndUI/UI/LayerPanel/LayersAndMisc/PaletteVBoxContainer/CenterContainer/PaletteButtons/EditPalette" to="." method="_on_EditPalette_pressed"] +[connection signal="item_selected" from="MenuAndUI/UI/LayerPanel/LayersAndMisc/PaletteVBoxContainer/CenterContainer/PaletteButtons/PaletteOptionButton" to="." method="_on_PaletteOptionButton_item_selected"] [connection signal="pressed" from="MenuAndUI/UI/LayerPanel/LayersAndMisc/LayerVBoxContainer/CenterLayerButtons/LayerButtons/AddLayer" to="." method="add_layer"] [connection signal="pressed" from="MenuAndUI/UI/LayerPanel/LayersAndMisc/LayerVBoxContainer/CenterLayerButtons/LayerButtons/RemoveLayer" to="." method="_on_RemoveLayerButton_pressed"] [connection signal="pressed" from="MenuAndUI/UI/LayerPanel/LayersAndMisc/LayerVBoxContainer/CenterLayerButtons/LayerButtons/MoveUpLayer" to="." method="change_layer_order" binds= [ 1 ]] diff --git a/Scripts/Global.gd b/Scripts/Global.gd index f2a7d40de..39f35cc75 100644 --- a/Scripts/Global.gd +++ b/Scripts/Global.gd @@ -207,9 +207,8 @@ var layer_opacity_slider : HSlider var layer_opacity_spinbox : SpinBox var add_palette_button : TextureButton -var remove_palette_button : TextureButton -var palette_option_button : OptionButton var edit_palette_button : BaseButton +var palette_option_button : OptionButton var palette_container : GridContainer var edit_palette_popup : WindowDialog var new_palette_dialog : ConfirmationDialog @@ -324,9 +323,8 @@ func _ready() -> void: vbox_layer_container = find_node_by_name(layer_stuff_container, "VBoxLayerContainer") add_palette_button = find_node_by_name(root, "AddPalette") - remove_palette_button = find_node_by_name(root, "RemovePalette") - palette_option_button = find_node_by_name(root, "PaletteOptionButton") edit_palette_button = find_node_by_name(root, "EditPalette") + palette_option_button = find_node_by_name(root, "PaletteOptionButton") palette_container = find_node_by_name(root, "PaletteContainer") edit_palette_popup = find_node_by_name(root, "EditPalettePopup") new_palette_dialog = find_node_by_name(root, "NewPaletteDialog") diff --git a/Scripts/Main.gd b/Scripts/Main.gd index d89646ce2..02ef7e4fb 100644 --- a/Scripts/Main.gd +++ b/Scripts/Main.gd @@ -924,16 +924,13 @@ func _on_QuitDialog_confirmed() -> void: func _on_AddPalette_pressed() -> void: Global.add_palette_button.get_child(0).popup(Rect2(Global.add_palette_button.rect_global_position, Vector2.ONE)) -func _on_RemovePalette_pressed() -> void: - Global.palette_container.remove_current_palette() +func _on_EditPalette_pressed() -> void: + Global.palette_container.on_edit_palette() func _on_PaletteOptionButton_item_selected(ID) -> void: var palette_name = Global.palette_option_button.get_item_metadata(ID) Global.palette_container.on_palette_select(palette_name) -func _on_EditPalette_pressed() -> void: - Global.palette_container.on_edit_palette() - func add_palette_menu_id_pressed(id) -> void: match id: 0: # New Empty Palette diff --git a/Scripts/Palette/PaletteContainer.gd b/Scripts/Palette/PaletteContainer.gd index 15016c15b..14b958b9c 100644 --- a/Scripts/Palette/PaletteContainer.gd +++ b/Scripts/Palette/PaletteContainer.gd @@ -7,7 +7,6 @@ const custom_palettes_path := "Palettes/Custom" var current_palette = "Default" var from_palette : Palette -# Called when the node enters the scene tree for the first time. func _ready() -> void: _load_palettes() @@ -22,14 +21,9 @@ func _clear_swatches() -> void: func on_palette_select(palette_name : String) -> void: _clear_swatches() - if Global.palettes.has(palette_name): #Palette exists in memory + if Global.palettes.has(palette_name): # Palette exists in memory current_palette = palette_name var palette : Palette = Global.palettes[palette_name] - - Global.remove_palette_button.disabled = true # Cannot remove by default - if palette.editable: - Global.remove_palette_button.disabled = false # Can remove if custom palette - _display_palette(palette) func on_new_empty_palette() -> void: @@ -189,24 +183,8 @@ func get_palette_files(path : String) -> Array: results.append(file_name) dir.list_dir_end() - return results -func remove_current_palette() -> void: - if Global.palettes[current_palette].editable: - _delete_palette_file(current_palette + ".json") - Global.palettes.erase(current_palette) - var selected_index: int = Global.palette_option_button.selected - Global.palette_option_button.remove_item(selected_index) - if(selected_index - 1 >= 0): - Global.palette_option_button.select(selected_index - 1) - on_palette_select(Global.palette_option_button.get_item_metadata(selected_index - 1)) - -func _delete_palette_file(file_name : String) -> void: - var dir = Directory.new() - dir.remove(custom_palettes_path.plus_file(file_name)) - func save_palette(palette_name : String, filename : String) -> void: var palette = Global.palettes[palette_name] - palette.save_to_file(custom_palettes_path.plus_file(filename))