From 30cd607c6581f367e9df4387f3136faaf0a9e1fc Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Wed, 29 Jul 2020 20:06:20 +0300 Subject: [PATCH] Made "ImageEffects" node a separate scene The ImageEffects node is the parent of all image effect dialogs --- src/Main.tscn | 42 +++--------------------------- src/UI/Dialogs/GradientDialog.gd | 4 +++ src/UI/Dialogs/GradientDialog.tscn | 1 + src/UI/Dialogs/HSVDialog.gd | 4 +++ src/UI/Dialogs/HSVDialog.tscn | 1 + src/UI/Dialogs/ImageEffects.tscn | 35 +++++++++++++++++++++++++ src/UI/Dialogs/OutlineDialog.gd | 4 +++ src/UI/Dialogs/OutlineDialog.tscn | 1 + src/UI/Dialogs/ResizeCanvas.gd | 4 +++ src/UI/Dialogs/ResizeCanvas.tscn | 1 + src/UI/Dialogs/RotateImage.gd | 4 +++ src/UI/Dialogs/RotateImage.tscn | 1 + src/UI/Dialogs/ScaleImage.gd | 4 +++ src/UI/Dialogs/ScaleImage.tscn | 1 + src/UI/Dialogs/ShaderEffect.gd | 4 +-- 15 files changed, 70 insertions(+), 41 deletions(-) create mode 100644 src/UI/Dialogs/ImageEffects.tscn diff --git a/src/Main.tscn b/src/Main.tscn index eaee70651..ceb557c00 100644 --- a/src/Main.tscn +++ b/src/Main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=22 format=2] +[gd_scene load_steps=16 format=2] [ext_resource path="res://assets/themes/dark/theme.tres" type="Theme" id=1] [ext_resource path="res://src/Main.gd" type="Script" id=2] @@ -6,21 +6,15 @@ [ext_resource path="res://src/UI/UI.tscn" type="PackedScene" id=4] [ext_resource path="res://src/UI/PatternsPopup.tscn" type="PackedScene" id=5] [ext_resource path="res://src/UI/BrushesPopup.tscn" type="PackedScene" id=6] -[ext_resource path="res://src/UI/Dialogs/ResizeCanvas.tscn" type="PackedScene" id=7] +[ext_resource path="res://src/UI/Dialogs/ImageEffects.tscn" type="PackedScene" id=7] [ext_resource path="res://src/UI/Dialogs/SaveSpriteHTML5.tscn" type="PackedScene" id=8] -[ext_resource path="res://src/UI/Dialogs/GradientDialog.tscn" type="PackedScene" id=9] -[ext_resource path="res://src/UI/Dialogs/ShaderEffect.tscn" type="PackedScene" id=10] [ext_resource path="res://src/UI/Dialogs/SaveSprite.tscn" type="PackedScene" id=11] [ext_resource path="res://src/UI/Dialogs/OpenSprite.tscn" type="PackedScene" id=12] [ext_resource path="res://src/UI/Dialogs/SplashDialog.tscn" type="PackedScene" id=27] [ext_resource path="res://src/UI/Dialogs/CreateNewImage.tscn" type="PackedScene" id=28] -[ext_resource path="res://src/UI/Dialogs/ScaleImage.tscn" type="PackedScene" id=31] [ext_resource path="res://src/Preferences/PreferencesDialog.tscn" type="PackedScene" id=32] -[ext_resource path="res://src/UI/Dialogs/OutlineDialog.tscn" type="PackedScene" id=33] [ext_resource path="res://src/UI/Dialogs/AboutDialog.tscn" type="PackedScene" id=34] -[ext_resource path="res://src/UI/Dialogs/RotateImage.tscn" type="PackedScene" id=38] [ext_resource path="res://src/UI/Dialogs/ExportDialog.tscn" type="PackedScene" id=39] -[ext_resource path="res://src/UI/Dialogs/HSVDialog.tscn" type="PackedScene" id=44] [node name="Control" type="Control"] anchor_right = 1.0 @@ -51,31 +45,7 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="ImageEffects" type="Control" parent="Dialogs"] -mouse_filter = 2 -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="ScaleImage" parent="Dialogs/ImageEffects" instance=ExtResource( 31 )] -margin_bottom = 127.0 - -[node name="ResizeCanvas" parent="Dialogs/ImageEffects" instance=ExtResource( 7 )] -margin_right = 216.0 -margin_bottom = 392.0 - -[node name="RotateImage" parent="Dialogs/ImageEffects" instance=ExtResource( 38 )] - -[node name="OutlineDialog" parent="Dialogs/ImageEffects" instance=ExtResource( 33 )] -margin_right = 217.0 -margin_bottom = 106.0 - -[node name="HSVDialog" parent="Dialogs/ImageEffects" instance=ExtResource( 44 )] - -[node name="GradientDialog" parent="Dialogs/ImageEffects" instance=ExtResource( 9 )] -margin_bottom = 214.0 - -[node name="ShaderEffect" parent="Dialogs/ImageEffects" instance=ExtResource( 10 )] +[node name="ImageEffects" parent="Dialogs" instance=ExtResource( 7 )] [node name="BrushesPopup" parent="Dialogs" instance=ExtResource( 6 )] @@ -146,12 +116,6 @@ visible = false visible = false [node name="ModulateTween" type="Tween" parent="."] -[connection signal="popup_hide" from="Dialogs/ImageEffects/ScaleImage" to="." method="_can_draw_true"] -[connection signal="popup_hide" from="Dialogs/ImageEffects/ResizeCanvas" to="." method="_can_draw_true"] -[connection signal="popup_hide" from="Dialogs/ImageEffects/RotateImage" to="." method="_can_draw_true"] -[connection signal="popup_hide" from="Dialogs/ImageEffects/OutlineDialog" to="." method="_can_draw_true"] -[connection signal="popup_hide" from="Dialogs/ImageEffects/HSVDialog" to="." method="_can_draw_true"] -[connection signal="popup_hide" from="Dialogs/ImageEffects/GradientDialog" to="." method="_can_draw_true"] [connection signal="popup_hide" from="Dialogs/SplashDialog" to="." method="_can_draw_true"] [connection signal="popup_hide" from="Dialogs/CreateNewImage" to="." method="_can_draw_true"] [connection signal="file_selected" from="Dialogs/OpenSprite" to="." method="_on_OpenSprite_file_selected"] diff --git a/src/UI/Dialogs/GradientDialog.gd b/src/UI/Dialogs/GradientDialog.gd index aff275be0..c967d565b 100644 --- a/src/UI/Dialogs/GradientDialog.gd +++ b/src/UI/Dialogs/GradientDialog.gd @@ -51,3 +51,7 @@ func _on_GradientDialog_confirmed() -> void: Global.canvas.handle_undo("Draw") DrawingAlgos.generate_gradient(current_cel, [color1.color, color2.color], steps.value, direction.selected) Global.canvas.handle_redo("Draw") + + +func _on_GradientDialog_popup_hide() -> void: + Global.dialog_open(false) diff --git a/src/UI/Dialogs/GradientDialog.tscn b/src/UI/Dialogs/GradientDialog.tscn index f92ff911e..af44cf2d5 100644 --- a/src/UI/Dialogs/GradientDialog.tscn +++ b/src/UI/Dialogs/GradientDialog.tscn @@ -101,6 +101,7 @@ items = [ "Top to Bottom", null, false, 0, null, "Bottom to Top", null, false, 1 selected = 0 [connection signal="about_to_show" from="." to="." method="_on_GradientDialog_about_to_show"] [connection signal="confirmed" from="." to="." method="_on_GradientDialog_confirmed"] +[connection signal="popup_hide" from="." to="." method="_on_GradientDialog_popup_hide"] [connection signal="color_changed" from="VBoxContainer/ColorsContainer/ColorPickerButton" to="." method="_on_ColorPickerButton_color_changed"] [connection signal="color_changed" from="VBoxContainer/ColorsContainer/ColorPickerButton2" to="." method="_on_ColorPickerButton2_color_changed"] [connection signal="value_changed" from="VBoxContainer/StepsContainer/StepSpinBox" to="." method="_on_StepSpinBox_value_changed"] diff --git a/src/UI/Dialogs/HSVDialog.gd b/src/UI/Dialogs/HSVDialog.gd index e222cd2d4..469c480e9 100644 --- a/src/UI/Dialogs/HSVDialog.gd +++ b/src/UI/Dialogs/HSVDialog.gd @@ -145,3 +145,7 @@ func _on_SelectionCheckBox_toggled(button_pressed : bool) -> void: func _on_AffectOptionButton_item_selected(index : int) -> void: affect = index + + +func _on_HSVDialog_popup_hide() -> void: + Global.dialog_open(false) diff --git a/src/UI/Dialogs/HSVDialog.tscn b/src/UI/Dialogs/HSVDialog.tscn index d327b85d1..fbf7294b3 100644 --- a/src/UI/Dialogs/HSVDialog.tscn +++ b/src/UI/Dialogs/HSVDialog.tscn @@ -177,6 +177,7 @@ mouse_default_cursor_shape = 2 size_flags_horizontal = 3 text = "Cancel" [connection signal="about_to_show" from="." to="." method="_on_HSVDialog_about_to_show"] +[connection signal="popup_hide" from="." to="." method="_on_HSVDialog_popup_hide"] [connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/Sliders/Hue" to="." method="_on_Hue_value_changed"] [connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/Sliders/Saturation" to="." method="_on_Saturation_value_changed"] [connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/Sliders/Value" to="." method="_on_Value_value_changed"] diff --git a/src/UI/Dialogs/ImageEffects.tscn b/src/UI/Dialogs/ImageEffects.tscn new file mode 100644 index 000000000..e0ee4b247 --- /dev/null +++ b/src/UI/Dialogs/ImageEffects.tscn @@ -0,0 +1,35 @@ +[gd_scene load_steps=8 format=2] + +[ext_resource path="res://src/UI/Dialogs/ResizeCanvas.tscn" type="PackedScene" id=8] +[ext_resource path="res://src/UI/Dialogs/RotateImage.tscn" type="PackedScene" id=9] +[ext_resource path="res://src/UI/Dialogs/ShaderEffect.tscn" type="PackedScene" id=10] +[ext_resource path="res://src/UI/Dialogs/HSVDialog.tscn" type="PackedScene" id=11] +[ext_resource path="res://src/UI/Dialogs/GradientDialog.tscn" type="PackedScene" id=12] +[ext_resource path="res://src/UI/Dialogs/OutlineDialog.tscn" type="PackedScene" id=13] +[ext_resource path="res://src/UI/Dialogs/ScaleImage.tscn" type="PackedScene" id=14] + +[node name="ImageEffects" type="Control"] +mouse_filter = 2 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ScaleImage" parent="." instance=ExtResource( 14 )] +margin_bottom = 127.0 + +[node name="ResizeCanvas" parent="." instance=ExtResource( 8 )] +margin_right = 216.0 +margin_bottom = 392.0 + +[node name="RotateImage" parent="." instance=ExtResource( 9 )] + +[node name="OutlineDialog" parent="." instance=ExtResource( 13 )] +margin_right = 217.0 +margin_bottom = 106.0 + +[node name="HSVDialog" parent="." instance=ExtResource( 11 )] + +[node name="GradientDialog" parent="." instance=ExtResource( 12 )] +margin_bottom = 214.0 + +[node name="ShaderEffect" parent="." instance=ExtResource( 10 )] diff --git a/src/UI/Dialogs/OutlineDialog.gd b/src/UI/Dialogs/OutlineDialog.gd index 74454ab26..38e146ade 100644 --- a/src/UI/Dialogs/OutlineDialog.gd +++ b/src/UI/Dialogs/OutlineDialog.gd @@ -108,3 +108,7 @@ func update_preview() -> void: func _on_AffectOptionButton_item_selected(index : int) -> void: affect = index + + +func _on_OutlineDialog_popup_hide() -> void: + Global.dialog_open(false) diff --git a/src/UI/Dialogs/OutlineDialog.tscn b/src/UI/Dialogs/OutlineDialog.tscn index cf87d6f2e..e65a1a378 100644 --- a/src/UI/Dialogs/OutlineDialog.tscn +++ b/src/UI/Dialogs/OutlineDialog.tscn @@ -99,6 +99,7 @@ items = [ "Current cel", null, false, 0, null, "Current frame", null, false, 1, selected = 0 [connection signal="about_to_show" from="." to="." method="_on_OutlineDialog_about_to_show"] [connection signal="confirmed" from="." to="." method="_on_OutlineDialog_confirmed"] +[connection signal="popup_hide" from="." to="." method="_on_OutlineDialog_popup_hide"] [connection signal="value_changed" from="VBoxContainer/OptionsContainer/ThickValue" to="." method="_on_ThickValue_value_changed"] [connection signal="color_changed" from="VBoxContainer/OptionsContainer/OutlineColor" to="." method="_on_OutlineColor_color_changed"] [connection signal="toggled" from="VBoxContainer/OptionsContainer/DiagonalCheckBox" to="." method="_on_DiagonalCheckBox_toggled"] diff --git a/src/UI/Dialogs/ResizeCanvas.gd b/src/UI/Dialogs/ResizeCanvas.gd index 310f45e39..f6f474b96 100644 --- a/src/UI/Dialogs/ResizeCanvas.gd +++ b/src/UI/Dialogs/ResizeCanvas.gd @@ -101,3 +101,7 @@ func update_transparent_background_size(preview_image : Image) -> void: preview_rect.get_node("TransparentChecker").rect_size.x = image_size_x preview_rect.get_node("TransparentChecker").rect_size.y = image_size_y + + +func _on_ResizeCanvas_popup_hide() -> void: + Global.dialog_open(false) diff --git a/src/UI/Dialogs/ResizeCanvas.tscn b/src/UI/Dialogs/ResizeCanvas.tscn index 19745bbb3..5773c4f8d 100644 --- a/src/UI/Dialogs/ResizeCanvas.tscn +++ b/src/UI/Dialogs/ResizeCanvas.tscn @@ -126,6 +126,7 @@ stretch_mode = 5 show_behind_parent = true [connection signal="about_to_show" from="." to="." method="_on_ResizeCanvas_about_to_show"] [connection signal="confirmed" from="." to="." method="_on_ResizeCanvas_confirmed"] +[connection signal="popup_hide" from="." to="." method="_on_ResizeCanvas_popup_hide"] [connection signal="value_changed" from="VBoxContainer/OptionsContainer/WidthValue" to="." method="_on_WidthValue_value_changed"] [connection signal="value_changed" from="VBoxContainer/OptionsContainer/HeightValue" to="." method="_on_HeightValue_value_changed"] [connection signal="value_changed" from="VBoxContainer/OptionsContainer/XSpinBox" to="." method="_on_XSpinBox_value_changed"] diff --git a/src/UI/Dialogs/RotateImage.gd b/src/UI/Dialogs/RotateImage.gd index 84785d4d0..d469cfbf6 100644 --- a/src/UI/Dialogs/RotateImage.gd +++ b/src/UI/Dialogs/RotateImage.gd @@ -58,3 +58,7 @@ func _on_OptionButton_item_selected(_id) -> void: func _on_RotateImage_about_to_show() -> void: $VBoxContainer/HBoxContainer/HSlider.value = 0 + + +func _on_RotateImage_popup_hide() -> void: + Global.dialog_open(false) diff --git a/src/UI/Dialogs/RotateImage.tscn b/src/UI/Dialogs/RotateImage.tscn index 48c5af573..a13c7fa6e 100644 --- a/src/UI/Dialogs/RotateImage.tscn +++ b/src/UI/Dialogs/RotateImage.tscn @@ -80,6 +80,7 @@ max_value = 359.0 suffix = "°" [connection signal="about_to_show" from="." to="." method="_on_RotateImage_about_to_show"] [connection signal="confirmed" from="." to="." method="_on_RotateImage_confirmed"] +[connection signal="popup_hide" from="." to="." method="_on_RotateImage_popup_hide"] [connection signal="item_selected" from="VBoxContainer/HBoxContainer2/OptionButton" to="." method="_on_OptionButton_item_selected"] [connection signal="value_changed" from="VBoxContainer/HBoxContainer/HSlider" to="." method="_on_HSlider_value_changed"] [connection signal="value_changed" from="VBoxContainer/HBoxContainer/SpinBox" to="." method="_on_SpinBox_value_changed"] diff --git a/src/UI/Dialogs/ScaleImage.gd b/src/UI/Dialogs/ScaleImage.gd index 1482774f8..bab0fd0a7 100644 --- a/src/UI/Dialogs/ScaleImage.gd +++ b/src/UI/Dialogs/ScaleImage.gd @@ -6,3 +6,7 @@ func _on_ScaleImage_confirmed() -> void: var height : int = $VBoxContainer/OptionsContainer/HeightValue.value var interpolation : int = $VBoxContainer/OptionsContainer/InterpolationType.selected DrawingAlgos.scale_image(width, height, interpolation) + + +func _on_ScaleImage_popup_hide() -> void: + Global.dialog_open(false) diff --git a/src/UI/Dialogs/ScaleImage.tscn b/src/UI/Dialogs/ScaleImage.tscn index 9bdc66aa1..958becfa4 100644 --- a/src/UI/Dialogs/ScaleImage.tscn +++ b/src/UI/Dialogs/ScaleImage.tscn @@ -74,3 +74,4 @@ text = "Nearest" items = [ "Nearest", null, false, 0, null, "Bilinear", null, false, 1, null, "Cubic", null, false, 2, null, "Trilinear", null, false, 3, null, "Lanczos", null, false, 4, null ] selected = 0 [connection signal="confirmed" from="." to="." method="_on_ScaleImage_confirmed"] +[connection signal="popup_hide" from="." to="." method="_on_ScaleImage_popup_hide"] diff --git a/src/UI/Dialogs/ShaderEffect.gd b/src/UI/Dialogs/ShaderEffect.gd index 4cf428ad4..64e695a69 100644 --- a/src/UI/Dialogs/ShaderEffect.gd +++ b/src/UI/Dialogs/ShaderEffect.gd @@ -81,9 +81,9 @@ func change_shader(shader : Shader, name : String) -> void: u_value = uniform_split[1].replace(";", "").strip_edges() var u_left_side = uniform_split[0].split(":") - var u_hint := "" + var _u_hint := "" if u_left_side.size() > 1: - u_hint = u_left_side[1].strip_edges() + _u_hint = u_left_side[1].strip_edges() var u_init = u_left_side[0].split(" ") var u_type = u_init[1]