From ce7320ad4f2a95c27924667282c6674eed6c4658 Mon Sep 17 00:00:00 2001 From: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Tue, 2 Feb 2021 17:48:17 +0200 Subject: [PATCH] Renamed "Base" to "BaseTool" and made it a class --- project.godot | 6 ++++++ src/Main.gd | 2 +- src/Tools/{Base.gd => BaseTool.gd} | 10 +++++----- src/Tools/{Base.tscn => BaseTool.tscn} | 2 +- src/Tools/Bucket.gd | 6 +++--- src/Tools/Bucket.tscn | 16 ++++++++-------- src/Tools/ColorPicker.gd | 4 ++-- src/Tools/ColorPicker.tscn | 2 +- src/Tools/Draw.gd | 2 +- src/Tools/Draw.tscn | 16 ++++++++-------- src/Tools/Pan.gd | 3 ++- src/Tools/Pan.tscn | 2 +- src/Tools/RectSelect.gd | 2 +- src/Tools/RectSelect.tscn | 2 +- src/Tools/Zoom.gd | 8 ++++---- src/Tools/Zoom.tscn | 2 +- src/UI/TransparentChecker.gd | 2 +- 17 files changed, 47 insertions(+), 40 deletions(-) rename src/Tools/{Base.gd => BaseTool.gd} (94%) rename src/Tools/{Base.tscn => BaseTool.tscn} (97%) diff --git a/project.godot b/project.godot index 9a68da5f1..0bc077fbb 100644 --- a/project.godot +++ b/project.godot @@ -14,6 +14,11 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://src/Classes/AnimationTag.gd" }, { +"base": "VBoxContainer", +"class": "BaseTool", +"language": "GDScript", +"path": "res://src/Tools/BaseTool.gd" +}, { "base": "Popup", "class": "Brushes", "language": "GDScript", @@ -86,6 +91,7 @@ _global_script_classes=[ { } ] _global_script_class_icons={ "AnimationTag": "", +"BaseTool": "", "Brushes": "", "Canvas": "", "Cel": "", diff --git a/src/Main.gd b/src/Main.gd index 8ff932c29..0c016b731 100644 --- a/src/Main.gd +++ b/src/Main.gd @@ -16,7 +16,7 @@ func _ready() -> void: alternate_transparent_background.anchor_top = ANCHOR_BEGIN alternate_transparent_background.anchor_right = ANCHOR_END alternate_transparent_background.anchor_bottom = ANCHOR_END - + get_tree().set_auto_accept_quit(false) setup_application_window_size() diff --git a/src/Tools/Base.gd b/src/Tools/BaseTool.gd similarity index 94% rename from src/Tools/Base.gd rename to src/Tools/BaseTool.gd index 2eac06798..d5675e452 100644 --- a/src/Tools/Base.gd +++ b/src/Tools/BaseTool.gd @@ -1,4 +1,4 @@ -extends VBoxContainer +class_name BaseTool extends VBoxContainer var kname : String @@ -8,7 +8,7 @@ var cursor_text := "" var _cursor := Vector2.INF -func _ready(): +func _ready() -> void: kname = name.replace(" ", "_").to_lower() $Label.text = tool_slot.name @@ -19,12 +19,12 @@ func _ready(): $Mirror/Vertical.pressed = tool_slot.vertical_mirror -func _on_PixelPerfect_toggled(button_pressed : bool): +func _on_PixelPerfect_toggled(button_pressed : bool) -> void: tool_slot.pixel_perfect = button_pressed tool_slot.save_config() -func _on_Horizontal_toggled(button_pressed : bool): +func _on_Horizontal_toggled(button_pressed : bool) -> void: tool_slot.horizontal_mirror = button_pressed tool_slot.save_config() Global.show_y_symmetry_axis = button_pressed @@ -34,7 +34,7 @@ func _on_Horizontal_toggled(button_pressed : bool): Global.current_project.y_symmetry_axis.visible = Global.show_y_symmetry_axis and Global.show_guides -func _on_Vertical_toggled(button_pressed : bool): +func _on_Vertical_toggled(button_pressed : bool) -> void: tool_slot.vertical_mirror = button_pressed tool_slot.save_config() Global.show_x_symmetry_axis = button_pressed diff --git a/src/Tools/Base.tscn b/src/Tools/BaseTool.tscn similarity index 97% rename from src/Tools/Base.tscn rename to src/Tools/BaseTool.tscn index 74bc53d67..356f1b151 100644 --- a/src/Tools/Base.tscn +++ b/src/Tools/BaseTool.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=6 format=2] -[ext_resource path="res://src/Tools/Base.gd" type="Script" id=1] +[ext_resource path="res://src/Tools/BaseTool.gd" type="Script" id=1] [ext_resource path="res://assets/graphics/dark_themes/tools/horizontal_mirror_on.png" type="Texture" id=2] [ext_resource path="res://assets/graphics/dark_themes/tools/horizontal_mirror_off.png" type="Texture" id=3] [ext_resource path="res://assets/graphics/dark_themes/tools/vertical_mirror_on.png" type="Texture" id=4] diff --git a/src/Tools/Bucket.gd b/src/Tools/Bucket.gd index aff4522f1..3d37d7c71 100644 --- a/src/Tools/Bucket.gd +++ b/src/Tools/Bucket.gd @@ -1,4 +1,4 @@ -extends "res://src/Tools/Base.gd" +extends BaseTool var _pattern : Patterns.Pattern @@ -35,13 +35,13 @@ func _on_Pattern_selected(pattern : Patterns.Pattern) -> void: save_config() -func _on_PatternOffsetX_value_changed(value : float): +func _on_PatternOffsetX_value_changed(value : float) -> void: _offset_x = int(value) update_config() save_config() -func _on_PatternOffsetY_value_changed(value : float): +func _on_PatternOffsetY_value_changed(value : float) -> void: _offset_y = int(value) update_config() save_config() diff --git a/src/Tools/Bucket.tscn b/src/Tools/Bucket.tscn index 19ee76312..36977d03d 100644 --- a/src/Tools/Bucket.tscn +++ b/src/Tools/Bucket.tscn @@ -1,9 +1,9 @@ [gd_scene load_steps=5 format=2] -[ext_resource path="res://src/Tools/Base.tscn" type="PackedScene" id=2] +[ext_resource path="res://src/Tools/BaseTool.tscn" type="PackedScene" id=2] [ext_resource path="res://src/Tools/Bucket.gd" type="Script" id=3] -[sub_resource type="StyleBoxFlat" id=2] +[sub_resource type="StyleBoxFlat" id=1] bg_color = Color( 1, 1, 1, 1 ) border_color = Color( 1, 1, 1, 1 ) corner_radius_top_left = 5 @@ -12,7 +12,7 @@ corner_radius_bottom_right = 5 corner_radius_bottom_left = 5 anti_aliasing = false -[sub_resource type="StyleBoxFlat" id=1] +[sub_resource type="StyleBoxFlat" id=2] bg_color = Color( 1, 1, 1, 1 ) border_color = Color( 1, 1, 1, 1 ) corner_radius_top_left = 5 @@ -81,11 +81,11 @@ rect_min_size = Vector2( 32, 32 ) hint_tooltip = "Select a brush" mouse_default_cursor_shape = 2 size_flags_horizontal = 4 -custom_styles/hover = SubResource( 2 ) -custom_styles/pressed = SubResource( 2 ) -custom_styles/focus = SubResource( 1 ) -custom_styles/disabled = SubResource( 1 ) -custom_styles/normal = SubResource( 2 ) +custom_styles/hover = SubResource( 1 ) +custom_styles/pressed = SubResource( 1 ) +custom_styles/focus = SubResource( 2 ) +custom_styles/disabled = SubResource( 2 ) +custom_styles/normal = SubResource( 1 ) [node name="Texture" type="TextureRect" parent="FillPattern/Type" index="0"] margin_right = 32.0 diff --git a/src/Tools/ColorPicker.gd b/src/Tools/ColorPicker.gd index 45866fc29..b839ea074 100644 --- a/src/Tools/ColorPicker.gd +++ b/src/Tools/ColorPicker.gd @@ -1,10 +1,10 @@ -extends "res://src/Tools/Base.gd" +extends BaseTool var _color_slot := 0 -func _on_Options_item_selected(id): +func _on_Options_item_selected(id : int) -> void: _color_slot = id update_config() save_config() diff --git a/src/Tools/ColorPicker.tscn b/src/Tools/ColorPicker.tscn index c230814c5..d9e2db0c0 100644 --- a/src/Tools/ColorPicker.tscn +++ b/src/Tools/ColorPicker.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=2] -[ext_resource path="res://src/Tools/Base.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/Tools/BaseTool.tscn" type="PackedScene" id=1] [ext_resource path="res://src/Tools/ColorPicker.gd" type="Script" id=2] [node name="ToolOptions" instance=ExtResource( 1 )] diff --git a/src/Tools/Draw.gd b/src/Tools/Draw.gd index 47a776543..88ef126a5 100644 --- a/src/Tools/Draw.gd +++ b/src/Tools/Draw.gd @@ -1,4 +1,4 @@ -extends "res://src/Tools/Base.gd" +extends BaseTool var _brush := Brushes.get_default_brush() diff --git a/src/Tools/Draw.tscn b/src/Tools/Draw.tscn index 2727ac8e7..2f51935fe 100644 --- a/src/Tools/Draw.tscn +++ b/src/Tools/Draw.tscn @@ -1,9 +1,9 @@ [gd_scene load_steps=5 format=2] -[ext_resource path="res://src/Tools/Base.tscn" type="PackedScene" id=2] +[ext_resource path="res://src/Tools/BaseTool.tscn" type="PackedScene" id=2] [ext_resource path="res://src/Tools/Draw.gd" type="Script" id=3] -[sub_resource type="StyleBoxFlat" id=2] +[sub_resource type="StyleBoxFlat" id=1] bg_color = Color( 1, 1, 1, 1 ) border_color = Color( 1, 1, 1, 1 ) corner_radius_top_left = 5 @@ -12,7 +12,7 @@ corner_radius_bottom_right = 5 corner_radius_bottom_left = 5 anti_aliasing = false -[sub_resource type="StyleBoxFlat" id=1] +[sub_resource type="StyleBoxFlat" id=2] bg_color = Color( 1, 1, 1, 1 ) border_color = Color( 1, 1, 1, 1 ) corner_radius_top_left = 5 @@ -38,11 +38,11 @@ rect_min_size = Vector2( 32, 32 ) hint_tooltip = "Select a brush" mouse_default_cursor_shape = 2 size_flags_horizontal = 0 -custom_styles/hover = SubResource( 2 ) -custom_styles/pressed = SubResource( 2 ) -custom_styles/focus = SubResource( 1 ) -custom_styles/disabled = SubResource( 1 ) -custom_styles/normal = SubResource( 2 ) +custom_styles/hover = SubResource( 1 ) +custom_styles/pressed = SubResource( 1 ) +custom_styles/focus = SubResource( 2 ) +custom_styles/disabled = SubResource( 2 ) +custom_styles/normal = SubResource( 1 ) [node name="Texture" type="TextureRect" parent="Brush/Type" index="0"] margin_right = 32.0 diff --git a/src/Tools/Pan.gd b/src/Tools/Pan.gd index 84e031cb8..78e4172e5 100644 --- a/src/Tools/Pan.gd +++ b/src/Tools/Pan.gd @@ -1,4 +1,5 @@ -extends "res://src/Tools/Base.gd" +extends BaseTool + func draw_start(_position : Vector2) -> void: Global.camera.drag = true diff --git a/src/Tools/Pan.tscn b/src/Tools/Pan.tscn index 2ad51df73..d5584a6e0 100644 --- a/src/Tools/Pan.tscn +++ b/src/Tools/Pan.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=2] -[ext_resource path="res://src/Tools/Base.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/Tools/BaseTool.tscn" type="PackedScene" id=1] [ext_resource path="res://src/Tools/Pan.gd" type="Script" id=2] [node name="ToolOptions" instance=ExtResource( 1 )] diff --git a/src/Tools/RectSelect.gd b/src/Tools/RectSelect.gd index 1543faa77..e4f10c8a5 100644 --- a/src/Tools/RectSelect.gd +++ b/src/Tools/RectSelect.gd @@ -1,4 +1,4 @@ -extends "res://src/Tools/Base.gd" +extends BaseTool var _start := Rect2(0, 0, 0, 0) diff --git a/src/Tools/RectSelect.tscn b/src/Tools/RectSelect.tscn index d557baaaf..374d6c600 100644 --- a/src/Tools/RectSelect.tscn +++ b/src/Tools/RectSelect.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=2] -[ext_resource path="res://src/Tools/Base.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/Tools/BaseTool.tscn" type="PackedScene" id=1] [ext_resource path="res://src/Tools/RectSelect.gd" type="Script" id=2] [node name="ToolOptions" instance=ExtResource( 1 )] diff --git a/src/Tools/Zoom.gd b/src/Tools/Zoom.gd index 75df8a3b2..ac5cddfd0 100644 --- a/src/Tools/Zoom.gd +++ b/src/Tools/Zoom.gd @@ -1,20 +1,20 @@ -extends "res://src/Tools/Base.gd" +extends BaseTool var _zoom_mode := 0 -func _on_ModeOptions_item_selected(id): +func _on_ModeOptions_item_selected(id : int) -> void: _zoom_mode = id update_config() save_config() -func _on_FitToFrame_pressed(): +func _on_FitToFrame_pressed() -> void: Global.camera.fit_to_frame(Global.current_project.size) -func _on_100_pressed(): +func _on_100_pressed() -> void: Global.camera.zoom_100() diff --git a/src/Tools/Zoom.tscn b/src/Tools/Zoom.tscn index 91bfbba8a..ae4adbb21 100644 --- a/src/Tools/Zoom.tscn +++ b/src/Tools/Zoom.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=2] -[ext_resource path="res://src/Tools/Base.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/Tools/BaseTool.tscn" type="PackedScene" id=1] [ext_resource path="res://src/Tools/Zoom.gd" type="Script" id=2] [node name="ToolOptions" instance=ExtResource( 1 )] diff --git a/src/UI/TransparentChecker.gd b/src/UI/TransparentChecker.gd index 2b7c11256..53c03d00c 100644 --- a/src/UI/TransparentChecker.gd +++ b/src/UI/TransparentChecker.gd @@ -37,7 +37,7 @@ func transparency(value :float) -> void: OS.window_per_pixel_transparency_enabled = true get_parent().transparent_bg = true get_tree().get_root().set_transparent_background(true) - + # this controls opacity 0 for transparent, 1 or a greater value than 1 is opaque # i have set a minimum amount for the fade (We would'nt want the canvas to dissapear now would we?) material.set("shader_param/alpha",clamp(value,0.1,1))