From 54604fa0afb220b477a0e67d5d3e0601950b26ff Mon Sep 17 00:00:00 2001 From: Variable <77773850+Variable-ind@users.noreply.github.com> Date: Wed, 20 Dec 2023 19:23:20 +0500 Subject: [PATCH] Allow Internal extensions (#963) * Moved tools to Extension * removed accidental change * code re-arrangement * some improvements * Restored tools and some improvements * typo * re-arranged tools * formatting --- src/Autoload/ExtensionsApi.gd | 63 ++++++++++--------- src/Autoload/Tools.gd | 56 +++++++++++------ src/Preferences/HandleExtensions.gd | 52 ++++++++++++--- src/Tools/{ => 3DTools}/3DShapeEdit.gd | 0 src/Tools/{ => 3DTools}/3DShapeEdit.tscn | 2 +- src/Tools/{Draw.gd => BaseDraw.gd} | 0 src/Tools/{Draw.tscn => BaseDraw.tscn} | 2 +- .../SelectionTool.gd => BaseSelectionTool.gd} | 2 +- ...ectionTool.tscn => BaseSelectionTool.tscn} | 2 +- .../{ShapeDrawer.gd => BaseShapeDrawer.gd} | 2 +- ...{ShapeDrawer.tscn => BaseShapeDrawer.tscn} | 4 +- src/Tools/BaseTool.tscn | 1 + src/Tools/{ => DesignTools}/Bucket.gd | 0 src/Tools/{ => DesignTools}/Bucket.tscn | 4 +- src/Tools/{ => DesignTools}/EllipseTool.gd | 2 +- src/Tools/{ => DesignTools}/EllipseTool.tscn | 4 +- src/Tools/{ => DesignTools}/Eraser.gd | 2 +- src/Tools/{ => DesignTools}/Eraser.tscn | 6 +- src/Tools/{ => DesignTools}/LineTool.gd | 2 +- src/Tools/{ => DesignTools}/LineTool.tscn | 6 +- src/Tools/{ => DesignTools}/Pencil.gd | 2 +- src/Tools/{ => DesignTools}/Pencil.tscn | 4 +- src/Tools/{ => DesignTools}/RectangleTool.gd | 2 +- .../{ => DesignTools}/RectangleTool.tscn | 4 +- src/Tools/{ => DesignTools}/Shading.gd | 2 +- src/Tools/{ => DesignTools}/Shading.tscn | 6 +- src/Tools/SelectionTools/ColorSelect.gd | 2 +- src/Tools/SelectionTools/ColorSelect.tscn | 4 +- src/Tools/SelectionTools/EllipseSelect.gd | 2 +- src/Tools/SelectionTools/EllipseSelect.tscn | 2 +- src/Tools/SelectionTools/Lasso.gd | 2 +- src/Tools/SelectionTools/Lasso.tscn | 2 +- src/Tools/SelectionTools/MagicWand.gd | 2 +- src/Tools/SelectionTools/MagicWand.tscn | 2 +- src/Tools/SelectionTools/PaintSelect.gd | 2 +- src/Tools/SelectionTools/PaintSelect.tscn | 2 +- src/Tools/SelectionTools/PolygonSelect.gd | 2 +- src/Tools/SelectionTools/PolygonSelect.tscn | 2 +- src/Tools/SelectionTools/RectSelect.gd | 2 +- src/Tools/SelectionTools/RectSelect.tscn | 2 +- src/Tools/{ => UtilityTools}/ColorPicker.gd | 0 src/Tools/{ => UtilityTools}/ColorPicker.tscn | 2 +- src/Tools/{ => UtilityTools}/CropTool.gd | 0 src/Tools/{ => UtilityTools}/CropTool.tscn | 4 +- src/Tools/{ => UtilityTools}/Move.gd | 0 src/Tools/{ => UtilityTools}/Move.tscn | 2 +- src/Tools/{ => UtilityTools}/Pan.gd | 0 src/Tools/{ => UtilityTools}/Pan.tscn | 2 +- src/Tools/{ => UtilityTools}/Zoom.gd | 0 src/Tools/{ => UtilityTools}/Zoom.tscn | 2 +- src/UI/Canvas/CameraMovement.gd | 2 +- src/UI/Canvas/Selection.gd | 4 +- src/{Tools => UI/ToolsPanel}/ToolButton.tscn | 16 +++-- src/UI/{Tools => ToolsPanel}/ToolButtons.gd | 0 src/UI/{Tools => ToolsPanel}/Tools.tscn | 2 +- src/UI/UI.tscn | 2 +- 56 files changed, 181 insertions(+), 119 deletions(-) rename src/Tools/{ => 3DTools}/3DShapeEdit.gd (100%) rename src/Tools/{ => 3DTools}/3DShapeEdit.tscn (99%) rename src/Tools/{Draw.gd => BaseDraw.gd} (100%) rename src/Tools/{Draw.tscn => BaseDraw.tscn} (97%) rename src/Tools/{SelectionTools/SelectionTool.gd => BaseSelectionTool.gd} (99%) rename src/Tools/{SelectionTools/SelectionTool.tscn => BaseSelectionTool.tscn} (94%) rename src/Tools/{ShapeDrawer.gd => BaseShapeDrawer.gd} (99%) rename src/Tools/{ShapeDrawer.tscn => BaseShapeDrawer.tscn} (89%) rename src/Tools/{ => DesignTools}/Bucket.gd (100%) rename src/Tools/{ => DesignTools}/Bucket.tscn (94%) rename src/Tools/{ => DesignTools}/EllipseTool.gd (98%) rename src/Tools/{ => DesignTools}/EllipseTool.tscn (60%) rename src/Tools/{ => DesignTools}/Eraser.gd (98%) rename src/Tools/{ => DesignTools}/Eraser.tscn (68%) rename src/Tools/{ => DesignTools}/LineTool.gd (99%) rename src/Tools/{ => DesignTools}/LineTool.tscn (71%) rename src/Tools/{ => DesignTools}/Pencil.gd (99%) rename src/Tools/{ => DesignTools}/Pencil.tscn (91%) rename src/Tools/{ => DesignTools}/RectangleTool.gd (96%) rename src/Tools/{ => DesignTools}/RectangleTool.tscn (60%) rename src/Tools/{ => DesignTools}/Shading.gd (99%) rename src/Tools/{ => DesignTools}/Shading.tscn (91%) rename src/Tools/{ => UtilityTools}/ColorPicker.gd (100%) rename src/Tools/{ => UtilityTools}/ColorPicker.tscn (94%) rename src/Tools/{ => UtilityTools}/CropTool.gd (100%) rename src/Tools/{ => UtilityTools}/CropTool.tscn (96%) rename src/Tools/{ => UtilityTools}/Move.gd (100%) rename src/Tools/{ => UtilityTools}/Move.tscn (75%) rename src/Tools/{ => UtilityTools}/Pan.gd (100%) rename src/Tools/{ => UtilityTools}/Pan.tscn (75%) rename src/Tools/{ => UtilityTools}/Zoom.gd (100%) rename src/Tools/{ => UtilityTools}/Zoom.tscn (94%) rename src/{Tools => UI/ToolsPanel}/ToolButton.tscn (78%) rename src/UI/{Tools => ToolsPanel}/ToolButtons.gd (100%) rename src/UI/{Tools => ToolsPanel}/Tools.tscn (86%) diff --git a/src/Autoload/ExtensionsApi.gd b/src/Autoload/ExtensionsApi.gd index 50a981873..46adabb2d 100644 --- a/src/Autoload/ExtensionsApi.gd +++ b/src/Autoload/ExtensionsApi.gd @@ -404,9 +404,11 @@ class ToolAPI: ## display name [param display_name], tool scene [param scene], layers that the tool works ## on [param layer_types] defined by [constant LayerTypes], ## [param extra_hint] (text that appears when mouse havers tool icon), primary shortcut - ## name [param shortcut] and any extra shortcuts [param extra_shortucts]. + ## name [param shortcut] and any extra shortcuts [param extra_shortcuts]. ## [br][br]At the moment extensions can't make their own shortcuts so you can ignore - ## [param shortcut] and [param extra_shortucts]. + ## [param shortcut] and [param extra_shortcuts]. + ## [br] to determine the position of tool in tool list, use [param insert_point] + ## (if you leave it empty then the added tool will be placed at bottom) func add_tool( tool_name: String, display_name: String, @@ -414,13 +416,14 @@ class ToolAPI: layer_types: PackedInt32Array = [], extra_hint := "", shortcut: String = "", - extra_shortucts: PackedStringArray = [] + extra_shortcuts: PackedStringArray = [], + insert_point := -1 ) -> void: var tool_class := Tools.Tool.new( - tool_name, display_name, shortcut, scene, layer_types, extra_hint, extra_shortucts + tool_name, display_name, shortcut, scene, layer_types, extra_hint, extra_shortcuts ) Tools.tools[tool_name] = tool_class - Tools.add_tool_button(tool_class) + Tools.add_tool_button(tool_class, insert_point) ExtensionsApi.add_action("ToolAPI", "add_tool") ## Removes a tool with name [param tool_name] @@ -723,8 +726,8 @@ class SignalsAPI: func _on_texture_changed(): texture_changed.emit() - func _connect_disconnect(signal_class: Signal, callable: Callable, disconnect := false): - if !disconnect: + func _connect_disconnect(signal_class: Signal, callable: Callable, is_disconnecting := false): + if !is_disconnecting: signal_class.connect(callable) ExtensionsApi.add_action("SignalsAPI", signal_class.get_name()) else: @@ -734,67 +737,69 @@ class SignalsAPI: # APP RELATED SIGNALS ## connects/disconnects a signal to [param callable], that emits ## when pixelorama is just opened. - func signal_pixelorama_opened(callable: Callable, disconnect := false): - _connect_disconnect(Global.pixelorama_opened, callable, disconnect) + func signal_pixelorama_opened(callable: Callable, is_disconnecting := false): + _connect_disconnect(Global.pixelorama_opened, callable, is_disconnecting) ## connects/disconnects a signal to [param callable], that emits ## when pixelorama is about to close. - func signal_pixelorama_about_to_close(callable: Callable, disconnect := false): - _connect_disconnect(Global.pixelorama_about_to_close, callable, disconnect) + func signal_pixelorama_about_to_close(callable: Callable, is_disconnecting := false): + _connect_disconnect(Global.pixelorama_about_to_close, callable, is_disconnecting) # PROJECT RELATED SIGNALS ## connects/disconnects a signal to [param callable], that emits ## whenever a new project is created.[br] ## [b]Binds: [/b]It has one bind of type [code]Project[/code] which is the newly created project - func signal_project_created(callable: Callable, disconnect := false): - _connect_disconnect(Global.project_created, callable, disconnect) + func signal_project_created(callable: Callable, is_disconnecting := false): + _connect_disconnect(Global.project_created, callable, is_disconnecting) ## connects/disconnects a signal to [param callable], that emits ## after a project is saved. - func signal_project_saved(callable: Callable, disconnect := false): - _connect_disconnect(OpenSave.project_saved, callable, disconnect) + func signal_project_saved(callable: Callable, is_disconnecting := false): + _connect_disconnect(OpenSave.project_saved, callable, is_disconnecting) ## connects/disconnects a signal to [param callable], that emits ## whenever you switch to some other project. - func signal_project_changed(callable: Callable, disconnect := false): - _connect_disconnect(Global.project_changed, callable, disconnect) + func signal_project_changed(callable: Callable, is_disconnecting := false): + _connect_disconnect(Global.project_changed, callable, is_disconnecting) ## connects/disconnects a signal to [param callable], that emits ## whenever you select a different cel. - func signal_cel_changed(callable: Callable, disconnect := false): - _connect_disconnect(Global.cel_changed, callable, disconnect) + func signal_cel_changed(callable: Callable, is_disconnecting := false): + _connect_disconnect(Global.cel_changed, callable, is_disconnecting) # TOOL RELATED SIGNALS ## connects/disconnects a signal to [param callable], that emits ## whenever a tool changes color.[br] ## [b]Binds: [/b] It has two bind of type [Color] (indicating new color) ## and [int] (Indicating button that tool is assigned to, see [enum @GlobalScope.MouseButton]) - func signal_tool_color_changed(callable: Callable, disconnect := false): - _connect_disconnect(Tools.color_changed, callable, disconnect) + func signal_tool_color_changed(callable: Callable, is_disconnecting := false): + _connect_disconnect(Tools.color_changed, callable, is_disconnecting) # TIMELINE RELATED SIGNALS ## connects/disconnects a signal to [param callable], that emits ## whenever timeline animation starts.[br] ## [b]Binds: [/b] It has one bind of type [bool] which indicated if animation is in ## forward direction ([code]true[/code]) or backward direction ([code]false[/code]) - func signal_timeline_animation_started(callable: Callable, disconnect := false): - _connect_disconnect(Global.animation_timeline.animation_started, callable, disconnect) + func signal_timeline_animation_started(callable: Callable, is_disconnecting := false): + _connect_disconnect(Global.animation_timeline.animation_started, callable, is_disconnecting) ## connects/disconnects a signal to [param callable], that emits ## whenever timeline animation stops. - func signal_timeline_animation_finished(callable: Callable, disconnect := false): - _connect_disconnect(Global.animation_timeline.animation_finished, callable, disconnect) + func signal_timeline_animation_finished(callable: Callable, is_disconnecting := false): + _connect_disconnect( + Global.animation_timeline.animation_finished, callable, is_disconnecting + ) # UPDATER SIGNALS ## connects/disconnects a signal to [param callable], that emits ## whenever texture of the currently focused cel changes. - func signal_current_cel_texture_changed(callable: Callable, disconnect := false): - _connect_disconnect(texture_changed, callable, disconnect) + func signal_current_cel_texture_changed(callable: Callable, is_disconnecting := false): + _connect_disconnect(texture_changed, callable, is_disconnecting) ## connects/disconnects a signal to [param callable], that emits ## whenever preview is about to be drawn.[br] ## [b]Binds: [/b]It has one bind of type [Dictionary] with keys: [code]exporter_id[/code], ## [code]export_tab[/code], [code]preview_images[/code], [code]durations[/code] ## [br] Use this if you plan on changing preview of export - func signal_export_about_to_preview(callable: Callable, disconnect := false): - _connect_disconnect(Global.export_dialog.about_to_preview, callable, disconnect) + func signal_export_about_to_preview(callable: Callable, is_disconnecting := false): + _connect_disconnect(Global.export_dialog.about_to_preview, callable, is_disconnecting) diff --git a/src/Autoload/Tools.gd b/src/Autoload/Tools.gd index 6201c16cf..89221d1bb 100644 --- a/src/Autoload/Tools.gd +++ b/src/Autoload/Tools.gd @@ -74,26 +74,35 @@ var tools := { "res://src/Tools/SelectionTools/PaintSelect.tscn" ), "Move": - Tool.new("Move", "Move", "move", "res://src/Tools/Move.tscn", [Global.LayerTypes.PIXEL]), - "Zoom": Tool.new("Zoom", "Zoom", "zoom", "res://src/Tools/Zoom.tscn"), - "Pan": Tool.new("Pan", "Pan", "pan", "res://src/Tools/Pan.tscn"), + Tool.new( + "Move", "Move", "move", "res://src/Tools/UtilityTools/Move.tscn", [Global.LayerTypes.PIXEL] + ), + "Zoom": Tool.new("Zoom", "Zoom", "zoom", "res://src/Tools/UtilityTools/Zoom.tscn"), + "Pan": Tool.new("Pan", "Pan", "pan", "res://src/Tools/UtilityTools/Pan.tscn"), "ColorPicker": Tool.new( "ColorPicker", "Color Picker", "colorpicker", - "res://src/Tools/ColorPicker.tscn", + "res://src/Tools/UtilityTools/ColorPicker.tscn", [], "Select a color from a pixel of the sprite" ), "Crop": - Tool.new("Crop", "Crop", "crop", "res://src/Tools/CropTool.tscn", [], "Resize the canvas"), + Tool.new( + "Crop", + "Crop", + "crop", + "res://src/Tools/UtilityTools/CropTool.tscn", + [], + "Resize the canvas" + ), "Pencil": Tool.new( "Pencil", "Pencil", "pencil", - "res://src/Tools/Pencil.tscn", + "res://src/Tools/DesignTools/Pencil.tscn", [Global.LayerTypes.PIXEL], "Hold %s to make a line", ["draw_create_line"] @@ -103,19 +112,25 @@ var tools := { "Eraser", "Eraser", "eraser", - "res://src/Tools/Eraser.tscn", + "res://src/Tools/DesignTools/Eraser.tscn", [Global.LayerTypes.PIXEL], "Hold %s to make a line", ["draw_create_line"] ), "Bucket": - Tool.new("Bucket", "Bucket", "fill", "res://src/Tools/Bucket.tscn", [Global.LayerTypes.PIXEL]), + Tool.new( + "Bucket", + "Bucket", + "fill", + "res://src/Tools/DesignTools/Bucket.tscn", + [Global.LayerTypes.PIXEL] + ), "Shading": Tool.new( "Shading", "Shading Tool", "shading", - "res://src/Tools/Shading.tscn", + "res://src/Tools/DesignTools/Shading.tscn", [Global.LayerTypes.PIXEL] ), "LineTool": @@ -125,7 +140,7 @@ var tools := { "LineTool", "Line Tool", "linetool", - "res://src/Tools/LineTool.tscn", + "res://src/Tools/DesignTools/LineTool.tscn", [Global.LayerTypes.PIXEL], """Hold %s to snap the angle of the line Hold %s to center the shape on the click origin @@ -140,7 +155,7 @@ Hold %s to displace the shape's origin""", "RectangleTool", "Rectangle Tool", "rectangletool", - "res://src/Tools/RectangleTool.tscn", + "res://src/Tools/DesignTools/RectangleTool.tscn", [Global.LayerTypes.PIXEL], """Hold %s to create a 1:1 shape Hold %s to center the shape on the click origin @@ -155,7 +170,7 @@ Hold %s to displace the shape's origin""", "EllipseTool", "Ellipse Tool", "ellipsetool", - "res://src/Tools/EllipseTool.tscn", + "res://src/Tools/DesignTools/EllipseTool.tscn", [Global.LayerTypes.PIXEL], """Hold %s to create a 1:1 shape Hold %s to center the shape on the click origin @@ -168,12 +183,12 @@ Hold %s to displace the shape's origin""", "3DShapeEdit", "3D Shape Edit", "3dshapeedit", - "res://src/Tools/3DShapeEdit.tscn", + "res://src/Tools/3DTools/3DShapeEdit.tscn", [Global.LayerTypes.THREE_D] ), } -var _tool_button_scene := preload("res://src/Tools/ToolButton.tscn") +var _tool_button_scene := preload("res://src/UI/ToolsPanel/ToolButton.tscn") var _slots := {} var _panels := {} var _curr_layer_type := Global.LayerTypes.PIXEL @@ -210,7 +225,7 @@ class Tool: _scene_path: String, _layer_types: PackedInt32Array = [], _extra_hint := "", - _extra_shortucts: PackedStringArray = [] + _extra_shortcuts: PackedStringArray = [] ) -> void: name = _name display_name = _display_name @@ -218,7 +233,7 @@ class Tool: scene_path = _scene_path layer_types = _layer_types extra_hint = _extra_hint - extra_shortcuts = _extra_shortucts + extra_shortcuts = _extra_shortcuts icon = load("res://assets/graphics/tools/%s.png" % name.to_lower()) cursor_icon = load("res://assets/graphics/tools/cursors/%s.png" % name.to_lower()) @@ -329,10 +344,13 @@ func _ready() -> void: update_tool_cursors() var layer: BaseLayer = Global.current_project.layers[Global.current_project.current_layer] var layer_type := layer.get_layer_type() + + # Yield is necessary to hide irrelevant tools added by extensions + await get_tree().process_frame _show_relevant_tools(layer_type) -func add_tool_button(t: Tool) -> void: +func add_tool_button(t: Tool, insert_pos := -1) -> void: var tool_button: BaseButton = _tool_button_scene.instantiate() tool_button.name = t.name tool_button.get_node("BackgroundLeft").modulate = Global.left_tool_color @@ -341,6 +359,9 @@ func add_tool_button(t: Tool) -> void: tool_button.tooltip_text = t.generate_hint_tooltip() t.button_node = tool_button _tool_buttons.add_child(tool_button) + if insert_pos > -1: + insert_pos = min(insert_pos, _tool_buttons.get_child_count() - 1) + _tool_buttons.move_child(tool_button, insert_pos) tool_button.pressed.connect(_tool_buttons._on_Tool_pressed.bind(tool_button)) @@ -432,7 +453,6 @@ func update_tool_buttons() -> void: func update_hint_tooltips() -> void: - await get_tree().process_frame for tool_name in tools: var t: Tool = tools[tool_name] t.button_node.tooltip_text = t.generate_hint_tooltip() diff --git a/src/Preferences/HandleExtensions.gd b/src/Preferences/HandleExtensions.gd index ea27bb525..0c0952e3d 100644 --- a/src/Preferences/HandleExtensions.gd +++ b/src/Preferences/HandleExtensions.gd @@ -25,7 +25,12 @@ class Extension: var version := "" var license := "" var nodes := [] - var enabled := false + var enabled: bool: + set(value): + enabled = value + enabled_once = true + var internal := false + var enabled_once := false func serialize(dict: Dictionary) -> void: if dict.has("name"): @@ -50,6 +55,8 @@ func _ready() -> void: $HBoxContainer/AddExtensionButton.disabled = true $HBoxContainer/OpenFolderButton.visible = false + _add_internal_extensions() + var file_names: PackedStringArray = [] var dir := DirAccess.open("user://") dir.make_dir(EXTENSIONS_PATH) @@ -71,6 +78,13 @@ func _ready() -> void: _add_extension(file_name) +func _add_internal_extensions() -> void: + ## at the moment this is an empty function but you should add all internal extensions here + # for example: + #read_extension("ExtensionName", true) + pass + + func install_extension(path: String) -> void: var file_name := path.get_file() var err := DirAccess.copy_absolute(path, EXTENSIONS_PATH.path_join(file_name)) @@ -150,7 +164,6 @@ func _add_extension(file_name: String) -> void: await get_tree().process_frame await get_tree().process_frame - var file_name_no_ext := file_name.get_basename() var file_path := EXTENSIONS_PATH.path_join(file_name) var success := ProjectSettings.load_resource_pack(file_path) if !success: @@ -162,6 +175,11 @@ func _add_extension(file_name: String) -> void: # Delete the faulty.txt, (it's fate has already been decided) DirAccess.remove_absolute(EXTENSIONS_PATH.path_join("Faulty.txt")) return + read_extension(file_name) + + +func read_extension(extension_file_or_folder_name: StringName, internal := false): + var file_name_no_ext := extension_file_or_folder_name.get_basename() var extension_path := "res://src/Extensions/%s/" % file_name_no_ext var extension_config_file_path := extension_path.path_join("extension.json") var extension_config_file := FileAccess.open(extension_config_file_path, FileAccess.READ) @@ -198,24 +216,30 @@ func _add_extension(file_name: String) -> void: Global.error_dialog.popup_centered() Global.dialog_open(true) print("Incompatible API") - # Don't put it in faulty, (it's merely incompatible) - DirAccess.remove_absolute(EXTENSIONS_PATH.path_join("Faulty.txt")) + if !internal: # the file isn't created for internal extensions, no need for removal + # Don't put it in faulty, (it's merely incompatible) + DirAccess.remove_absolute(EXTENSIONS_PATH.path_join("Faulty.txt")) return var extension := Extension.new() extension.serialize(extension_json) - extensions[file_name] = extension + extension.internal = internal + extensions[extension_file_or_folder_name] = extension extension_list.add_item(extension.display_name) var item_count := extension_list.get_item_count() - 1 extension_list.set_item_tooltip(item_count, extension.description) - extension_list.set_item_metadata(item_count, file_name) - extension.enabled = Global.config_cache.get_value("extensions", extension.file_name, false) + extension_list.set_item_metadata(item_count, extension_file_or_folder_name) + if internal: # enable internal extensions if it is for the first time + extension.enabled = Global.config_cache.get_value("extensions", extension.file_name, true) + else: + extension.enabled = Global.config_cache.get_value("extensions", extension.file_name, false) if extension.enabled: _enable_extension(extension) # If an extension doesn't crash pixelorama then it is proven innocent # And we should now delete its "Faulty.txt" file - DirAccess.remove_absolute(EXTENSIONS_PATH.path_join("Faulty.txt")) + if !internal: # the file isn't created for internal extensions, so no need to remove it + DirAccess.remove_absolute(EXTENSIONS_PATH.path_join("Faulty.txt")) func _enable_extension(extension: Extension, save_to_config := true) -> void: @@ -258,7 +282,10 @@ func _on_InstalledExtensions_item_selected(index: int) -> void: else: enable_button.text = "Enable" enable_button.disabled = false - uninstall_button.disabled = false + if !extension.internal: + uninstall_button.disabled = false + else: + uninstall_button.disabled = true func _on_InstalledExtensions_empty_clicked(_position: Vector2, _button_index: int) -> void: @@ -274,7 +301,12 @@ func _on_EnableButton_pressed() -> void: var file_name: String = extension_list.get_item_metadata(extension_selected) var extension: Extension = extensions[file_name] extension.enabled = !extension.enabled - _enable_extension(extension) + # Don't allow disabling internal extensions through this button. + if extension.internal and extension.enabled_once: + Global.preferences_dialog.preference_update(true) + else: + _enable_extension(extension) + if extension.enabled: enable_button.text = "Disable" else: diff --git a/src/Tools/3DShapeEdit.gd b/src/Tools/3DTools/3DShapeEdit.gd similarity index 100% rename from src/Tools/3DShapeEdit.gd rename to src/Tools/3DTools/3DShapeEdit.gd diff --git a/src/Tools/3DShapeEdit.tscn b/src/Tools/3DTools/3DShapeEdit.tscn similarity index 99% rename from src/Tools/3DShapeEdit.tscn rename to src/Tools/3DTools/3DShapeEdit.tscn index 7f3cb1676..6944a7737 100644 --- a/src/Tools/3DShapeEdit.tscn +++ b/src/Tools/3DTools/3DShapeEdit.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=10 format=3 uid="uid://cg7d36746on67"] [ext_resource type="PackedScene" uid="uid://ctfgfelg0sho8" path="res://src/Tools/BaseTool.tscn" id="1"] -[ext_resource type="Script" path="res://src/Tools/3DShapeEdit.gd" id="2"] +[ext_resource type="Script" path="res://src/Tools/3DTools/3DShapeEdit.gd" id="2"] [ext_resource type="PackedScene" path="res://src/UI/Nodes/ValueSliderV2.tscn" id="3"] [ext_resource type="PackedScene" uid="uid://yjhp0ssng2mp" path="res://src/UI/Nodes/ValueSlider.tscn" id="4"] [ext_resource type="Script" path="res://src/UI/Nodes/ValueSlider.gd" id="5"] diff --git a/src/Tools/Draw.gd b/src/Tools/BaseDraw.gd similarity index 100% rename from src/Tools/Draw.gd rename to src/Tools/BaseDraw.gd diff --git a/src/Tools/Draw.tscn b/src/Tools/BaseDraw.tscn similarity index 97% rename from src/Tools/Draw.tscn rename to src/Tools/BaseDraw.tscn index 48053198e..b05261e56 100644 --- a/src/Tools/Draw.tscn +++ b/src/Tools/BaseDraw.tscn @@ -2,7 +2,7 @@ [ext_resource type="PackedScene" uid="uid://yjhp0ssng2mp" path="res://src/UI/Nodes/ValueSlider.tscn" id="1"] [ext_resource type="PackedScene" uid="uid://ctfgfelg0sho8" path="res://src/Tools/BaseTool.tscn" id="2"] -[ext_resource type="Script" path="res://src/Tools/Draw.gd" id="3"] +[ext_resource type="Script" path="res://src/Tools/BaseDraw.gd" id="3"] [sub_resource type="StyleBoxFlat" id="1"] bg_color = Color(1, 1, 1, 1) diff --git a/src/Tools/SelectionTools/SelectionTool.gd b/src/Tools/BaseSelectionTool.gd similarity index 99% rename from src/Tools/SelectionTools/SelectionTool.gd rename to src/Tools/BaseSelectionTool.gd index c796cd6ca..0195c8826 100644 --- a/src/Tools/SelectionTools/SelectionTool.gd +++ b/src/Tools/BaseSelectionTool.gd @@ -1,4 +1,4 @@ -class_name SelectionTool +class_name BaseSelectionTool extends BaseTool enum Mode { DEFAULT, ADD, SUBTRACT, INTERSECT } diff --git a/src/Tools/SelectionTools/SelectionTool.tscn b/src/Tools/BaseSelectionTool.tscn similarity index 94% rename from src/Tools/SelectionTools/SelectionTool.tscn rename to src/Tools/BaseSelectionTool.tscn index 23f95a726..a600f1d5a 100644 --- a/src/Tools/SelectionTools/SelectionTool.tscn +++ b/src/Tools/BaseSelectionTool.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=3 uid="uid://bd62qfjn380wf"] [ext_resource type="PackedScene" uid="uid://ctfgfelg0sho8" path="res://src/Tools/BaseTool.tscn" id="1"] -[ext_resource type="Script" path="res://src/Tools/SelectionTools/SelectionTool.gd" id="2"] +[ext_resource type="Script" path="res://src/Tools/BaseSelectionTool.gd" id="2"] [ext_resource type="PackedScene" path="res://src/UI/Nodes/ValueSliderV2.tscn" id="4"] [node name="ToolOptions" instance=ExtResource("1")] diff --git a/src/Tools/ShapeDrawer.gd b/src/Tools/BaseShapeDrawer.gd similarity index 99% rename from src/Tools/ShapeDrawer.gd rename to src/Tools/BaseShapeDrawer.gd index c894675a1..72503f365 100644 --- a/src/Tools/ShapeDrawer.gd +++ b/src/Tools/BaseShapeDrawer.gd @@ -1,4 +1,4 @@ -extends "res://src/Tools/Draw.gd" +extends "res://src/Tools/BaseDraw.gd" var _start := Vector2i.ZERO var _offset := Vector2i.ZERO diff --git a/src/Tools/ShapeDrawer.tscn b/src/Tools/BaseShapeDrawer.tscn similarity index 89% rename from src/Tools/ShapeDrawer.tscn rename to src/Tools/BaseShapeDrawer.tscn index 554e278db..3d7c6c2a4 100644 --- a/src/Tools/ShapeDrawer.tscn +++ b/src/Tools/BaseShapeDrawer.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=3 uid="uid://n40lhf8hm7o1"] -[ext_resource type="Script" path="res://src/Tools/ShapeDrawer.gd" id="1"] -[ext_resource type="PackedScene" uid="uid://ubyatap3sylf" path="res://src/Tools/Draw.tscn" id="2"] +[ext_resource type="Script" path="res://src/Tools/BaseShapeDrawer.gd" id="1"] +[ext_resource type="PackedScene" uid="uid://ubyatap3sylf" path="res://src/Tools/BaseDraw.tscn" id="2"] [ext_resource type="PackedScene" uid="uid://yjhp0ssng2mp" path="res://src/UI/Nodes/ValueSlider.tscn" id="3"] [node name="ToolOptions" instance=ExtResource("2")] diff --git a/src/Tools/BaseTool.tscn b/src/Tools/BaseTool.tscn index 4803a9711..5f61dda19 100644 --- a/src/Tools/BaseTool.tscn +++ b/src/Tools/BaseTool.tscn @@ -18,3 +18,4 @@ layout_mode = 2 layout_mode = 2 theme_type_variation = &"HeaderSmall" text = "Tool Name" +horizontal_alignment = 1 diff --git a/src/Tools/Bucket.gd b/src/Tools/DesignTools/Bucket.gd similarity index 100% rename from src/Tools/Bucket.gd rename to src/Tools/DesignTools/Bucket.gd diff --git a/src/Tools/Bucket.tscn b/src/Tools/DesignTools/Bucket.tscn similarity index 94% rename from src/Tools/Bucket.tscn rename to src/Tools/DesignTools/Bucket.tscn index e59f7039c..376c96ed0 100644 --- a/src/Tools/Bucket.tscn +++ b/src/Tools/DesignTools/Bucket.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=6 format=3 uid="uid://bbvvkrrjyxugo"] -[ext_resource type="PackedScene" path="res://src/UI/Nodes/ValueSlider.tscn" id="1"] +[ext_resource type="PackedScene" uid="uid://yjhp0ssng2mp" path="res://src/UI/Nodes/ValueSlider.tscn" id="1"] [ext_resource type="PackedScene" uid="uid://ctfgfelg0sho8" path="res://src/Tools/BaseTool.tscn" id="2"] -[ext_resource type="Script" path="res://src/Tools/Bucket.gd" id="3"] +[ext_resource type="Script" path="res://src/Tools/DesignTools/Bucket.gd" id="3"] [sub_resource type="StyleBoxFlat" id="1"] bg_color = Color(1, 1, 1, 1) diff --git a/src/Tools/EllipseTool.gd b/src/Tools/DesignTools/EllipseTool.gd similarity index 98% rename from src/Tools/EllipseTool.gd rename to src/Tools/DesignTools/EllipseTool.gd index e5e0a7829..3f76c9664 100644 --- a/src/Tools/EllipseTool.gd +++ b/src/Tools/DesignTools/EllipseTool.gd @@ -1,4 +1,4 @@ -extends "res://src/Tools/ShapeDrawer.gd" +extends "res://src/Tools/BaseShapeDrawer.gd" func _get_shape_points_filled(shape_size: Vector2i) -> Array[Vector2i]: diff --git a/src/Tools/EllipseTool.tscn b/src/Tools/DesignTools/EllipseTool.tscn similarity index 60% rename from src/Tools/EllipseTool.tscn rename to src/Tools/DesignTools/EllipseTool.tscn index 04674337c..73e036658 100644 --- a/src/Tools/EllipseTool.tscn +++ b/src/Tools/DesignTools/EllipseTool.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://4hp76lf38bc7"] -[ext_resource type="PackedScene" uid="uid://n40lhf8hm7o1" path="res://src/Tools/ShapeDrawer.tscn" id="1"] -[ext_resource type="Script" path="res://src/Tools/EllipseTool.gd" id="2"] +[ext_resource type="PackedScene" uid="uid://n40lhf8hm7o1" path="res://src/Tools/BaseShapeDrawer.tscn" id="1"] +[ext_resource type="Script" path="res://src/Tools/DesignTools/EllipseTool.gd" id="2"] [node name="ToolOptions" instance=ExtResource("1")] script = ExtResource("2") diff --git a/src/Tools/Eraser.gd b/src/Tools/DesignTools/Eraser.gd similarity index 98% rename from src/Tools/Eraser.gd rename to src/Tools/DesignTools/Eraser.gd index c0b2598bb..e5870e8ab 100644 --- a/src/Tools/Eraser.gd +++ b/src/Tools/DesignTools/Eraser.gd @@ -1,4 +1,4 @@ -extends "res://src/Tools/Draw.gd" +extends "res://src/Tools/BaseDraw.gd" var _last_position := Vector2.INF var _clear_image: Image diff --git a/src/Tools/Eraser.tscn b/src/Tools/DesignTools/Eraser.tscn similarity index 68% rename from src/Tools/Eraser.tscn rename to src/Tools/DesignTools/Eraser.tscn index fcb2e9204..1a8354f47 100644 --- a/src/Tools/Eraser.tscn +++ b/src/Tools/DesignTools/Eraser.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=4 format=3 uid="uid://btmbrqqig7wys"] -[ext_resource type="PackedScene" uid="uid://ubyatap3sylf" path="res://src/Tools/Draw.tscn" id="1"] -[ext_resource type="Script" path="res://src/Tools/Eraser.gd" id="2"] -[ext_resource type="PackedScene" path="res://src/UI/Nodes/ValueSlider.tscn" id="3"] +[ext_resource type="PackedScene" uid="uid://ubyatap3sylf" path="res://src/Tools/BaseDraw.tscn" id="1"] +[ext_resource type="Script" path="res://src/Tools/DesignTools/Eraser.gd" id="2"] +[ext_resource type="PackedScene" uid="uid://yjhp0ssng2mp" path="res://src/UI/Nodes/ValueSlider.tscn" id="3"] [node name="ToolOptions" instance=ExtResource("1")] script = ExtResource("2") diff --git a/src/Tools/LineTool.gd b/src/Tools/DesignTools/LineTool.gd similarity index 99% rename from src/Tools/LineTool.gd rename to src/Tools/DesignTools/LineTool.gd index f11078f16..aee81550e 100644 --- a/src/Tools/LineTool.gd +++ b/src/Tools/DesignTools/LineTool.gd @@ -1,4 +1,4 @@ -extends "res://src/Tools/Draw.gd" +extends "res://src/Tools/BaseDraw.gd" var _original_pos := Vector2i.ZERO var _start := Vector2i.ZERO diff --git a/src/Tools/LineTool.tscn b/src/Tools/DesignTools/LineTool.tscn similarity index 71% rename from src/Tools/LineTool.tscn rename to src/Tools/DesignTools/LineTool.tscn index 94793fc36..4b42e2899 100644 --- a/src/Tools/LineTool.tscn +++ b/src/Tools/DesignTools/LineTool.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=4 format=3 uid="uid://ceahf2toaq47l"] -[ext_resource type="PackedScene" uid="uid://ubyatap3sylf" path="res://src/Tools/Draw.tscn" id="1"] -[ext_resource type="Script" path="res://src/Tools/LineTool.gd" id="2"] -[ext_resource type="PackedScene" path="res://src/UI/Nodes/ValueSlider.tscn" id="3"] +[ext_resource type="PackedScene" uid="uid://ubyatap3sylf" path="res://src/Tools/BaseDraw.tscn" id="1"] +[ext_resource type="Script" path="res://src/Tools/DesignTools/LineTool.gd" id="2"] +[ext_resource type="PackedScene" uid="uid://yjhp0ssng2mp" path="res://src/UI/Nodes/ValueSlider.tscn" id="3"] [node name="ToolOptions" instance=ExtResource("1")] script = ExtResource("2") diff --git a/src/Tools/Pencil.gd b/src/Tools/DesignTools/Pencil.gd similarity index 99% rename from src/Tools/Pencil.gd rename to src/Tools/DesignTools/Pencil.gd index 77897b691..c429b70ec 100644 --- a/src/Tools/Pencil.gd +++ b/src/Tools/DesignTools/Pencil.gd @@ -1,4 +1,4 @@ -extends "res://src/Tools/Draw.gd" +extends "res://src/Tools/BaseDraw.gd" var _prev_mode := false var _last_position := Vector2i(Vector2.INF) diff --git a/src/Tools/Pencil.tscn b/src/Tools/DesignTools/Pencil.tscn similarity index 91% rename from src/Tools/Pencil.tscn rename to src/Tools/DesignTools/Pencil.tscn index c51efb6e9..40ae6992c 100644 --- a/src/Tools/Pencil.tscn +++ b/src/Tools/DesignTools/Pencil.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=4 format=3 uid="uid://cul5mpy17ebfl"] -[ext_resource type="PackedScene" uid="uid://ubyatap3sylf" path="res://src/Tools/Draw.tscn" id="1"] +[ext_resource type="PackedScene" uid="uid://ubyatap3sylf" path="res://src/Tools/BaseDraw.tscn" id="1"] [ext_resource type="PackedScene" path="res://src/UI/Nodes/ValueSliderV2.tscn" id="2"] -[ext_resource type="Script" path="res://src/Tools/Pencil.gd" id="3"] +[ext_resource type="Script" path="res://src/Tools/DesignTools/Pencil.gd" id="3"] [node name="ToolOptions" instance=ExtResource("1")] script = ExtResource("3") diff --git a/src/Tools/RectangleTool.gd b/src/Tools/DesignTools/RectangleTool.gd similarity index 96% rename from src/Tools/RectangleTool.gd rename to src/Tools/DesignTools/RectangleTool.gd index a5324e3ae..55e75429e 100644 --- a/src/Tools/RectangleTool.gd +++ b/src/Tools/DesignTools/RectangleTool.gd @@ -1,4 +1,4 @@ -extends "res://src/Tools/ShapeDrawer.gd" +extends "res://src/Tools/BaseShapeDrawer.gd" func _get_shape_points_filled(shape_size: Vector2i) -> Array[Vector2i]: diff --git a/src/Tools/RectangleTool.tscn b/src/Tools/DesignTools/RectangleTool.tscn similarity index 60% rename from src/Tools/RectangleTool.tscn rename to src/Tools/DesignTools/RectangleTool.tscn index c04add273..a2aa05834 100644 --- a/src/Tools/RectangleTool.tscn +++ b/src/Tools/DesignTools/RectangleTool.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://dhlab4q2dwu0a"] -[ext_resource type="PackedScene" uid="uid://n40lhf8hm7o1" path="res://src/Tools/ShapeDrawer.tscn" id="1"] -[ext_resource type="Script" path="res://src/Tools/RectangleTool.gd" id="2"] +[ext_resource type="PackedScene" uid="uid://n40lhf8hm7o1" path="res://src/Tools/BaseShapeDrawer.tscn" id="1"] +[ext_resource type="Script" path="res://src/Tools/DesignTools/RectangleTool.gd" id="2"] [node name="ToolOptions" instance=ExtResource("1")] script = ExtResource("2") diff --git a/src/Tools/Shading.gd b/src/Tools/DesignTools/Shading.gd similarity index 99% rename from src/Tools/Shading.gd rename to src/Tools/DesignTools/Shading.gd index a61f89825..a07fd22fb 100644 --- a/src/Tools/Shading.gd +++ b/src/Tools/DesignTools/Shading.gd @@ -1,4 +1,4 @@ -extends "res://src/Tools/Draw.gd" +extends "res://src/Tools/BaseDraw.gd" enum ShadingMode { SIMPLE, HUE_SHIFTING } enum LightenDarken { LIGHTEN, DARKEN } diff --git a/src/Tools/Shading.tscn b/src/Tools/DesignTools/Shading.tscn similarity index 91% rename from src/Tools/Shading.tscn rename to src/Tools/DesignTools/Shading.tscn index bb070d5a3..79b731d0d 100644 --- a/src/Tools/Shading.tscn +++ b/src/Tools/DesignTools/Shading.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=4 format=3 uid="uid://rbyd7i6snxjc"] -[ext_resource type="PackedScene" uid="uid://ubyatap3sylf" path="res://src/Tools/Draw.tscn" id="1"] -[ext_resource type="Script" path="res://src/Tools/Shading.gd" id="2"] -[ext_resource type="PackedScene" path="res://src/UI/Nodes/ValueSlider.tscn" id="3"] +[ext_resource type="PackedScene" uid="uid://ubyatap3sylf" path="res://src/Tools/BaseDraw.tscn" id="1"] +[ext_resource type="Script" path="res://src/Tools/DesignTools/Shading.gd" id="2"] +[ext_resource type="PackedScene" uid="uid://yjhp0ssng2mp" path="res://src/UI/Nodes/ValueSlider.tscn" id="3"] [node name="ToolOptions" instance=ExtResource("1")] script = ExtResource("2") diff --git a/src/Tools/SelectionTools/ColorSelect.gd b/src/Tools/SelectionTools/ColorSelect.gd index 2157f07a7..a6fa33e5b 100644 --- a/src/Tools/SelectionTools/ColorSelect.gd +++ b/src/Tools/SelectionTools/ColorSelect.gd @@ -1,4 +1,4 @@ -extends SelectionTool +extends BaseSelectionTool var shader := preload("res://src/Shaders/ColorSelect.gdshader") var _similarity := 100 diff --git a/src/Tools/SelectionTools/ColorSelect.tscn b/src/Tools/SelectionTools/ColorSelect.tscn index e2800b90e..58a404bd7 100644 --- a/src/Tools/SelectionTools/ColorSelect.tscn +++ b/src/Tools/SelectionTools/ColorSelect.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=4 format=3 uid="uid://bqr6hr0p3ew6a"] -[ext_resource type="PackedScene" uid="uid://bd62qfjn380wf" path="res://src/Tools/SelectionTools/SelectionTool.tscn" id="1"] +[ext_resource type="PackedScene" uid="uid://bd62qfjn380wf" path="res://src/Tools/BaseSelectionTool.tscn" id="1"] [ext_resource type="Script" path="res://src/Tools/SelectionTools/ColorSelect.gd" id="2"] -[ext_resource type="PackedScene" path="res://src/UI/Nodes/ValueSlider.tscn" id="3"] +[ext_resource type="PackedScene" uid="uid://yjhp0ssng2mp" path="res://src/UI/Nodes/ValueSlider.tscn" id="3"] [node name="ToolOptions" instance=ExtResource("1")] script = ExtResource("2") diff --git a/src/Tools/SelectionTools/EllipseSelect.gd b/src/Tools/SelectionTools/EllipseSelect.gd index 61799e8f5..dce89511d 100644 --- a/src/Tools/SelectionTools/EllipseSelect.gd +++ b/src/Tools/SelectionTools/EllipseSelect.gd @@ -1,4 +1,4 @@ -extends SelectionTool +extends BaseSelectionTool var _rect := Rect2i(0, 0, 0, 0) diff --git a/src/Tools/SelectionTools/EllipseSelect.tscn b/src/Tools/SelectionTools/EllipseSelect.tscn index a189f8eb7..706500e5a 100644 --- a/src/Tools/SelectionTools/EllipseSelect.tscn +++ b/src/Tools/SelectionTools/EllipseSelect.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://cf2gm1oypbm6m"] -[ext_resource type="PackedScene" uid="uid://bd62qfjn380wf" path="res://src/Tools/SelectionTools/SelectionTool.tscn" id="1"] +[ext_resource type="PackedScene" uid="uid://bd62qfjn380wf" path="res://src/Tools/BaseSelectionTool.tscn" id="1"] [ext_resource type="Script" path="res://src/Tools/SelectionTools/EllipseSelect.gd" id="2"] [node name="ToolOptions" instance=ExtResource("1")] diff --git a/src/Tools/SelectionTools/Lasso.gd b/src/Tools/SelectionTools/Lasso.gd index 74e2f219e..933f50374 100644 --- a/src/Tools/SelectionTools/Lasso.gd +++ b/src/Tools/SelectionTools/Lasso.gd @@ -1,4 +1,4 @@ -extends SelectionTool +extends BaseSelectionTool var _last_position := Vector2.INF var _draw_points: Array[Vector2i] = [] diff --git a/src/Tools/SelectionTools/Lasso.tscn b/src/Tools/SelectionTools/Lasso.tscn index af18882ea..3fec096ed 100644 --- a/src/Tools/SelectionTools/Lasso.tscn +++ b/src/Tools/SelectionTools/Lasso.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://cu37uo35mcfom"] -[ext_resource type="PackedScene" uid="uid://bd62qfjn380wf" path="res://src/Tools/SelectionTools/SelectionTool.tscn" id="1"] +[ext_resource type="PackedScene" uid="uid://bd62qfjn380wf" path="res://src/Tools/BaseSelectionTool.tscn" id="1"] [ext_resource type="Script" path="res://src/Tools/SelectionTools/Lasso.gd" id="2"] [node name="ToolOptions" instance=ExtResource("1")] diff --git a/src/Tools/SelectionTools/MagicWand.gd b/src/Tools/SelectionTools/MagicWand.gd index 2d3891bf8..f49979d8f 100644 --- a/src/Tools/SelectionTools/MagicWand.gd +++ b/src/Tools/SelectionTools/MagicWand.gd @@ -1,4 +1,4 @@ -extends SelectionTool +extends BaseSelectionTool ## Working array used as buffer for segments while flooding var _allegro_flood_segments: Array[Segment] diff --git a/src/Tools/SelectionTools/MagicWand.tscn b/src/Tools/SelectionTools/MagicWand.tscn index 263e4a4f9..827220847 100644 --- a/src/Tools/SelectionTools/MagicWand.tscn +++ b/src/Tools/SelectionTools/MagicWand.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://blt8u6nvg1k3g"] -[ext_resource type="PackedScene" uid="uid://bd62qfjn380wf" path="res://src/Tools/SelectionTools/SelectionTool.tscn" id="1"] +[ext_resource type="PackedScene" uid="uid://bd62qfjn380wf" path="res://src/Tools/BaseSelectionTool.tscn" id="1"] [ext_resource type="Script" path="res://src/Tools/SelectionTools/MagicWand.gd" id="2"] [node name="ToolOptions" instance=ExtResource("1")] diff --git a/src/Tools/SelectionTools/PaintSelect.gd b/src/Tools/SelectionTools/PaintSelect.gd index 9f787fc7e..a2fc98df8 100644 --- a/src/Tools/SelectionTools/PaintSelect.gd +++ b/src/Tools/SelectionTools/PaintSelect.gd @@ -1,4 +1,4 @@ -extends SelectionTool +extends BaseSelectionTool var _brush_size := 2 var _brush := Brushes.get_default_brush() diff --git a/src/Tools/SelectionTools/PaintSelect.tscn b/src/Tools/SelectionTools/PaintSelect.tscn index 0fef4f9e3..0661e653e 100644 --- a/src/Tools/SelectionTools/PaintSelect.tscn +++ b/src/Tools/SelectionTools/PaintSelect.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=6 format=3 uid="uid://bry4ltxur56u7"] -[ext_resource type="PackedScene" uid="uid://bd62qfjn380wf" path="res://src/Tools/SelectionTools/SelectionTool.tscn" id="1"] +[ext_resource type="PackedScene" uid="uid://bd62qfjn380wf" path="res://src/Tools/BaseSelectionTool.tscn" id="1"] [ext_resource type="Script" path="res://src/Tools/SelectionTools/PaintSelect.gd" id="2"] [ext_resource type="PackedScene" uid="uid://yjhp0ssng2mp" path="res://src/UI/Nodes/ValueSlider.tscn" id="3"] diff --git a/src/Tools/SelectionTools/PolygonSelect.gd b/src/Tools/SelectionTools/PolygonSelect.gd index 1ab5b5661..7de01760f 100644 --- a/src/Tools/SelectionTools/PolygonSelect.gd +++ b/src/Tools/SelectionTools/PolygonSelect.gd @@ -1,4 +1,4 @@ -extends SelectionTool +extends BaseSelectionTool var _last_position := Vector2i(Vector2.INF) var _draw_points: Array[Vector2i] = [] diff --git a/src/Tools/SelectionTools/PolygonSelect.tscn b/src/Tools/SelectionTools/PolygonSelect.tscn index d28ddefdb..300453070 100644 --- a/src/Tools/SelectionTools/PolygonSelect.tscn +++ b/src/Tools/SelectionTools/PolygonSelect.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://dv8bn8gys3tax"] -[ext_resource type="PackedScene" uid="uid://bd62qfjn380wf" path="res://src/Tools/SelectionTools/SelectionTool.tscn" id="1"] +[ext_resource type="PackedScene" uid="uid://bd62qfjn380wf" path="res://src/Tools/BaseSelectionTool.tscn" id="1"] [ext_resource type="Script" path="res://src/Tools/SelectionTools/PolygonSelect.gd" id="2"] [node name="ToolOptions" instance=ExtResource("1")] diff --git a/src/Tools/SelectionTools/RectSelect.gd b/src/Tools/SelectionTools/RectSelect.gd index 6912e5f0f..96c718ffc 100644 --- a/src/Tools/SelectionTools/RectSelect.gd +++ b/src/Tools/SelectionTools/RectSelect.gd @@ -1,4 +1,4 @@ -extends SelectionTool +extends BaseSelectionTool var _rect := Rect2i() diff --git a/src/Tools/SelectionTools/RectSelect.tscn b/src/Tools/SelectionTools/RectSelect.tscn index fa518992c..b7e2e898e 100644 --- a/src/Tools/SelectionTools/RectSelect.tscn +++ b/src/Tools/SelectionTools/RectSelect.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://iph72k1ii717"] -[ext_resource type="PackedScene" uid="uid://bd62qfjn380wf" path="res://src/Tools/SelectionTools/SelectionTool.tscn" id="1"] +[ext_resource type="PackedScene" uid="uid://bd62qfjn380wf" path="res://src/Tools/BaseSelectionTool.tscn" id="1"] [ext_resource type="Script" path="res://src/Tools/SelectionTools/RectSelect.gd" id="2"] [node name="ToolOptions" instance=ExtResource("1")] diff --git a/src/Tools/ColorPicker.gd b/src/Tools/UtilityTools/ColorPicker.gd similarity index 100% rename from src/Tools/ColorPicker.gd rename to src/Tools/UtilityTools/ColorPicker.gd diff --git a/src/Tools/ColorPicker.tscn b/src/Tools/UtilityTools/ColorPicker.tscn similarity index 94% rename from src/Tools/ColorPicker.tscn rename to src/Tools/UtilityTools/ColorPicker.tscn index 8551c878f..bf381d666 100644 --- a/src/Tools/ColorPicker.tscn +++ b/src/Tools/UtilityTools/ColorPicker.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://2onobu8eymt8"] [ext_resource type="PackedScene" uid="uid://ctfgfelg0sho8" path="res://src/Tools/BaseTool.tscn" id="1"] -[ext_resource type="Script" path="res://src/Tools/ColorPicker.gd" id="2"] +[ext_resource type="Script" path="res://src/Tools/UtilityTools/ColorPicker.gd" id="2"] [node name="ToolOptions" instance=ExtResource("1")] script = ExtResource("2") diff --git a/src/Tools/CropTool.gd b/src/Tools/UtilityTools/CropTool.gd similarity index 100% rename from src/Tools/CropTool.gd rename to src/Tools/UtilityTools/CropTool.gd diff --git a/src/Tools/CropTool.tscn b/src/Tools/UtilityTools/CropTool.tscn similarity index 96% rename from src/Tools/CropTool.tscn rename to src/Tools/UtilityTools/CropTool.tscn index 2e550bc61..239422a11 100644 --- a/src/Tools/CropTool.tscn +++ b/src/Tools/UtilityTools/CropTool.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=6 format=3 uid="uid://c35n21ii7onhe"] [ext_resource type="PackedScene" uid="uid://ctfgfelg0sho8" path="res://src/Tools/BaseTool.tscn" id="1"] -[ext_resource type="PackedScene" path="res://src/UI/Nodes/ValueSlider.tscn" id="2"] -[ext_resource type="Script" path="res://src/Tools/CropTool.gd" id="3"] +[ext_resource type="PackedScene" uid="uid://yjhp0ssng2mp" path="res://src/UI/Nodes/ValueSlider.tscn" id="2"] +[ext_resource type="Script" path="res://src/Tools/UtilityTools/CropTool.gd" id="3"] [ext_resource type="Texture2D" uid="uid://bgrq56ndc4ydj" path="res://assets/graphics/misc/unlocked_size.png" id="4"] [ext_resource type="PackedScene" path="res://src/UI/Nodes/ValueSliderV2.tscn" id="5"] diff --git a/src/Tools/Move.gd b/src/Tools/UtilityTools/Move.gd similarity index 100% rename from src/Tools/Move.gd rename to src/Tools/UtilityTools/Move.gd diff --git a/src/Tools/Move.tscn b/src/Tools/UtilityTools/Move.tscn similarity index 75% rename from src/Tools/Move.tscn rename to src/Tools/UtilityTools/Move.tscn index ef057e531..32d842ce8 100644 --- a/src/Tools/Move.tscn +++ b/src/Tools/UtilityTools/Move.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://64l4dmyfeev7"] [ext_resource type="PackedScene" uid="uid://ctfgfelg0sho8" path="res://src/Tools/BaseTool.tscn" id="1"] -[ext_resource type="Script" path="res://src/Tools/Move.gd" id="2"] +[ext_resource type="Script" path="res://src/Tools/UtilityTools/Move.gd" id="2"] [node name="ToolOptions" instance=ExtResource("1")] script = ExtResource("2") diff --git a/src/Tools/Pan.gd b/src/Tools/UtilityTools/Pan.gd similarity index 100% rename from src/Tools/Pan.gd rename to src/Tools/UtilityTools/Pan.gd diff --git a/src/Tools/Pan.tscn b/src/Tools/UtilityTools/Pan.tscn similarity index 75% rename from src/Tools/Pan.tscn rename to src/Tools/UtilityTools/Pan.tscn index 02f3d3dcf..b38442cd7 100644 --- a/src/Tools/Pan.tscn +++ b/src/Tools/UtilityTools/Pan.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://pvno2bc0jepk"] [ext_resource type="PackedScene" uid="uid://ctfgfelg0sho8" path="res://src/Tools/BaseTool.tscn" id="1"] -[ext_resource type="Script" path="res://src/Tools/Pan.gd" id="2"] +[ext_resource type="Script" path="res://src/Tools/UtilityTools/Pan.gd" id="2"] [node name="ToolOptions" instance=ExtResource("1")] script = ExtResource("2") diff --git a/src/Tools/Zoom.gd b/src/Tools/UtilityTools/Zoom.gd similarity index 100% rename from src/Tools/Zoom.gd rename to src/Tools/UtilityTools/Zoom.gd diff --git a/src/Tools/Zoom.tscn b/src/Tools/UtilityTools/Zoom.tscn similarity index 94% rename from src/Tools/Zoom.tscn rename to src/Tools/UtilityTools/Zoom.tscn index b0bdc9e5e..763713c17 100644 --- a/src/Tools/Zoom.tscn +++ b/src/Tools/UtilityTools/Zoom.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://qyxbkvju2fbb"] [ext_resource type="PackedScene" uid="uid://ctfgfelg0sho8" path="res://src/Tools/BaseTool.tscn" id="1"] -[ext_resource type="Script" path="res://src/Tools/Zoom.gd" id="2"] +[ext_resource type="Script" path="res://src/Tools/UtilityTools/Zoom.gd" id="2"] [node name="ToolOptions" instance=ExtResource("1")] script = ExtResource("2") diff --git a/src/UI/Canvas/CameraMovement.gd b/src/UI/Canvas/CameraMovement.gd index 04794ca2d..335b3da5b 100644 --- a/src/UI/Canvas/CameraMovement.gd +++ b/src/UI/Canvas/CameraMovement.gd @@ -105,7 +105,7 @@ func _input(event: InputEvent) -> void: func _has_selection_tool() -> bool: for slot in Tools._slots.values(): - if slot.tool_node is SelectionTool: + if slot.tool_node is BaseSelectionTool: return true return false diff --git a/src/UI/Canvas/Selection.gd b/src/UI/Canvas/Selection.gd index 61ec4fdd4..659b65f08 100644 --- a/src/UI/Canvas/Selection.gd +++ b/src/UI/Canvas/Selection.gd @@ -14,7 +14,7 @@ var big_bounding_rectangle := Rect2i(): set(value): big_bounding_rectangle = value for slot in Tools._slots.values(): - if slot.tool_node is SelectionTool: + if slot.tool_node is BaseSelectionTool: slot.tool_node.set_spinbox_values() _update_gizmos() var image_current_pixel := Vector2.ZERO ## The ACTUAL pixel coordinate of image @@ -182,7 +182,7 @@ func _input(event: InputEvent) -> void: func _move_with_arrow_keys(event: InputEvent) -> void: var selection_tool_selected := false for slot in Tools._slots.values(): - if slot.tool_node is SelectionTool: + if slot.tool_node is BaseSelectionTool: selection_tool_selected = true break if !selection_tool_selected: diff --git a/src/Tools/ToolButton.tscn b/src/UI/ToolsPanel/ToolButton.tscn similarity index 78% rename from src/Tools/ToolButton.tscn rename to src/UI/ToolsPanel/ToolButton.tscn index 7b7076bf6..36c2d20d5 100644 --- a/src/Tools/ToolButton.tscn +++ b/src/UI/ToolsPanel/ToolButton.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=4 format=3 uid="uid://ddrry0n03t66c"] -[ext_resource type="Texture2D" uid="uid://cnomk15kl7go0" path="res://assets/graphics/tools/tool_background.png" id="1"] -[ext_resource type="Texture2D" uid="uid://chg3ejelsgcwm" path="res://assets/graphics/tools/rectselect.png" id="2"] -[ext_resource type="Texture2D" uid="uid://4h6t2v7tf6r2" path="res://assets/graphics/tools/tool_background_right.png" id="2_sxm2f"] +[ext_resource type="Texture2D" uid="uid://cnomk15kl7go0" path="res://assets/graphics/tools/tool_background.png" id="1_voklp"] +[ext_resource type="Texture2D" uid="uid://4h6t2v7tf6r2" path="res://assets/graphics/tools/tool_background_right.png" id="2_v8t3o"] +[ext_resource type="Texture2D" uid="uid://chg3ejelsgcwm" path="res://assets/graphics/tools/rectselect.png" id="3_hl32r"] [node name="Tool" type="Button" groups=["UIButtons"]] custom_minimum_size = Vector2(24, 24) @@ -16,12 +16,13 @@ mouse_default_cursor_shape = 2 button_mask = 3 [node name="BackgroundLeft" type="NinePatchRect" parent="."] +visible = false layout_mode = 1 anchors_preset = -1 anchor_right = 0.5 anchor_bottom = 1.0 grow_vertical = 2 -texture = ExtResource("1") +texture = ExtResource("1_voklp") region_rect = Rect2(0, 0, 11, 24) patch_margin_left = 2 patch_margin_top = 1 @@ -29,12 +30,13 @@ patch_margin_right = 10 patch_margin_bottom = 1 [node name="BackgroundRight" type="NinePatchRect" parent="."] +visible = false layout_mode = 1 anchors_preset = -1 anchor_left = 0.5 anchor_right = 1.0 anchor_bottom = 1.0 -texture = ExtResource("2_sxm2f") +texture = ExtResource("2_v8t3o") patch_margin_left = 11 patch_margin_top = 1 patch_margin_right = 1 @@ -51,4 +53,6 @@ offset_left = -11.0 offset_top = -11.0 offset_right = 11.0 offset_bottom = 11.0 -texture = ExtResource("2") +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("3_hl32r") diff --git a/src/UI/Tools/ToolButtons.gd b/src/UI/ToolsPanel/ToolButtons.gd similarity index 100% rename from src/UI/Tools/ToolButtons.gd rename to src/UI/ToolsPanel/ToolButtons.gd diff --git a/src/UI/Tools/Tools.tscn b/src/UI/ToolsPanel/Tools.tscn similarity index 86% rename from src/UI/Tools/Tools.tscn rename to src/UI/ToolsPanel/Tools.tscn index d0c812704..1545dcf0c 100644 --- a/src/UI/Tools/Tools.tscn +++ b/src/UI/ToolsPanel/Tools.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://byu3rtoipuvoc"] -[ext_resource type="Script" path="res://src/UI/Tools/ToolButtons.gd" id="1"] +[ext_resource type="Script" path="res://src/UI/ToolsPanel/ToolButtons.gd" id="1"] [node name="Tools" type="ScrollContainer"] custom_minimum_size = Vector2(36, 36) diff --git a/src/UI/UI.tscn b/src/UI/UI.tscn index ece1f6f1e..0eaf78183 100644 --- a/src/UI/UI.tscn +++ b/src/UI/UI.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=54 format=3 uid="uid://c8dsi6ggkqa7a"] -[ext_resource type="PackedScene" uid="uid://byu3rtoipuvoc" path="res://src/UI/Tools/Tools.tscn" id="1"] +[ext_resource type="PackedScene" uid="uid://byu3rtoipuvoc" path="res://src/UI/ToolsPanel/Tools.tscn" id="1"] [ext_resource type="PackedScene" uid="uid://c546tskdu53j1" path="res://src/UI/Canvas/CanvasPreview.tscn" id="2"] [ext_resource type="Script" path="res://src/UI/Tabs.gd" id="3"] [ext_resource type="Script" path="res://src/UI/Canvas/Rulers/VerticalRuler.gd" id="4"]