From 73891af5975344e84953bff439549bb202ab5e49 Mon Sep 17 00:00:00 2001 From: luiq54 Date: Fri, 17 Apr 2020 22:33:52 +0530 Subject: [PATCH] Brush Selection Fix --- Main.tscn | 3 +++ Scripts/BrushButton.gd | 3 +++ Scripts/Global.gd | 1 + Scripts/Main.gd | 2 ++ 4 files changed, 9 insertions(+) diff --git a/Main.tscn b/Main.tscn index 02b34dbd5..9b5f154e8 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1420,6 +1420,9 @@ visible = false [connection signal="pressed" from="MenuAndUI/UI/RightPanel/PreviewAndPalettes/ToolAndPaletteVSplit/PaletteVBoxContainer/CenterContainer/PaletteButtons/AddPalette" to="MenuAndUI/UI/RightPanel/PreviewAndPalettes/ToolAndPaletteVSplit/PaletteVBoxContainer/ScrollPalette/CenterPalette/PaletteContainer" method="_on_AddPalette_pressed"] [connection signal="pressed" from="MenuAndUI/UI/RightPanel/PreviewAndPalettes/ToolAndPaletteVSplit/PaletteVBoxContainer/CenterContainer/PaletteButtons/EditPalette" to="MenuAndUI/UI/RightPanel/PreviewAndPalettes/ToolAndPaletteVSplit/PaletteVBoxContainer/ScrollPalette/CenterPalette/PaletteContainer" method="on_edit_palette"] [connection signal="item_selected" from="MenuAndUI/UI/RightPanel/PreviewAndPalettes/ToolAndPaletteVSplit/PaletteVBoxContainer/CenterContainer/PaletteButtons/PaletteOptionButton" to="MenuAndUI/UI/RightPanel/PreviewAndPalettes/ToolAndPaletteVSplit/PaletteVBoxContainer/ScrollPalette/CenterPalette/PaletteContainer" method="_on_PaletteOptionButton_item_selected"] +[connection signal="brush_selected" from="BrushesPopup/TabContainer/File/FileBrushContainer/PixelBrushButton" to="." method="_on_Brush_Selected"] +[connection signal="brush_selected" from="BrushesPopup/TabContainer/File/FileBrushContainer/CircleBrushButton" to="." method="_on_Brush_Selected"] +[connection signal="brush_selected" from="BrushesPopup/TabContainer/File/FileBrushContainer/FilledCircleBrushButton" to="." method="_on_Brush_Selected"] [connection signal="popup_hide" from="SplashDialog" to="." method="_can_draw_true"] [connection signal="popup_hide" from="CreateNewImage" to="." method="_can_draw_true"] [connection signal="file_selected" from="OpenSprite" to="." method="_on_OpenSprite_file_selected"] diff --git a/Scripts/BrushButton.gd b/Scripts/BrushButton.gd index 89d76900c..8c50be0d0 100644 --- a/Scripts/BrushButton.gd +++ b/Scripts/BrushButton.gd @@ -4,6 +4,7 @@ export var brush_type = 0 # Global.Brush_Types.PIXEL export var custom_brush_index := -3 # warning-ignore:unused_class_variable var random_brushes := [] +signal brush_selected func _on_BrushButton_pressed() -> void: # Delete the brush on middle mouse press @@ -33,6 +34,7 @@ func _on_BrushButton_pressed() -> void: # Global.left_brush_type_label.text = tr("Brush: Filled Circle") Global.update_left_custom_brush() + emit_signal("brush_selected") else: # Change right brush Global.current_right_brush_type = brush_type @@ -55,6 +57,7 @@ func _on_BrushButton_pressed() -> void: # Global.right_brush_type_label.text = tr("Brush: Filled Circle") Global.update_right_custom_brush() + emit_signal("brush_selected") func _on_DeleteButton_pressed() -> void: if brush_type == Global.Brush_Types.CUSTOM: diff --git a/Scripts/Global.gd b/Scripts/Global.gd index b0c005120..2ba44db12 100644 --- a/Scripts/Global.gd +++ b/Scripts/Global.gd @@ -785,6 +785,7 @@ func create_brush_button(brush_img : Image, brush_type := Brush_Types.CUSTOM, hi brush_tex.create_from_image(brush_img, 0) brush_button.get_child(0).texture = brush_tex brush_button.hint_tooltip = hint_tooltip + brush_button.connect("brush_selected",control,"_on_Brush_Selected") if brush_type == Brush_Types.RANDOM_FILE: brush_button.random_brushes.append(brush_img) brush_container.add_child(brush_button) diff --git a/Scripts/Main.gd b/Scripts/Main.gd index 99fb2d27d..1d9f7d8bb 100644 --- a/Scripts/Main.gd +++ b/Scripts/Main.gd @@ -560,6 +560,8 @@ func _on_RightBrushSizeEdit_value_changed(value) -> void: Global.right_brush_size = new_size update_right_custom_brush() +func _on_Brush_Selected() -> void: + $BrushesPopup.hide() func _on_ColorSwitch_pressed() -> void: var temp: Color = Global.left_color_picker.color