From 495c3b8ebe1351a76e5941b6aac2bdf1b9d18828 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas Date: Thu, 7 Dec 2023 16:09:00 +0200 Subject: [PATCH] Don't call `project_changed()` whenever a reference image gets imported --- src/Autoload/Global.gd | 2 -- src/Autoload/OpenSave.gd | 5 +++-- src/Classes/Project.gd | 1 - src/UI/ReferenceImages/ReferenceImageButton.gd | 2 +- src/UI/ReferenceImages/ReferencesPanel.gd | 7 ++++++- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index 66a267cb5..dec4674dc 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -465,8 +465,6 @@ var cel_button_scene: PackedScene = load("res://src/UI/Timeline/CelButton.tscn") ## The palettes panel. It has the [param PalettePanel.gd] script attached. @onready var palette_panel: PalettePanel = control.find_child("Palettes") -## The reference images panel. It has the [param ReferencesPanel.gd] script attached. -@onready var references_panel: ReferencesPanel = control.find_child("Reference Images") ## The perspectice editor. It has the [param PerspectiveEditor.gd] script attached. @onready var perspective_editor := control.find_child("Perspective Editor") diff --git a/src/Autoload/OpenSave.gd b/src/Autoload/OpenSave.gd index dbe6932c5..946e675e7 100644 --- a/src/Autoload/OpenSave.gd +++ b/src/Autoload/OpenSave.gd @@ -2,6 +2,7 @@ extends Node signal project_saved +signal reference_image_imported var current_save_paths: PackedStringArray = [] ## Stores a filename of a backup file in user:// until user saves manually @@ -725,7 +726,7 @@ func import_reference_image_from_path(path: String) -> void: ri.project = project ri.deserialize({"image_path": path}) Global.canvas.add_child(ri) - project.change_project() + reference_image_imported.emit() ## Useful for Web @@ -735,7 +736,7 @@ func import_reference_image_from_image(image: Image) -> void: ri.project = project ri.create_from_image(image) Global.canvas.add_child(ri) - project.change_project() + reference_image_imported.emit() func set_new_imported_tab(project: Project, path: String) -> void: diff --git a/src/Classes/Project.gd b/src/Classes/Project.gd index 2e9c116ac..d64b2d76c 100644 --- a/src/Classes/Project.gd +++ b/src/Classes/Project.gd @@ -205,7 +205,6 @@ func change_project() -> void: Global.transparent_checker.update_rect() Global.animation_timeline.fps_spinbox.value = fps - Global.references_panel.project_changed() Global.perspective_editor.update_points() Global.cursor_position_label.text = "[%s×%s]" % [size.x, size.y] diff --git a/src/UI/ReferenceImages/ReferenceImageButton.gd b/src/UI/ReferenceImages/ReferenceImageButton.gd index aa789c68f..f162d99b3 100644 --- a/src/UI/ReferenceImages/ReferenceImageButton.gd +++ b/src/UI/ReferenceImages/ReferenceImageButton.gd @@ -46,7 +46,7 @@ func _on_Remove_pressed(): queue_free() element.queue_free() Global.current_project.reference_images.remove_at(index) - Global.current_project.change_project() + OpenSave.reference_image_imported.emit() func _on_Scale_value_changed(value: float): diff --git a/src/UI/ReferenceImages/ReferencesPanel.gd b/src/UI/ReferenceImages/ReferencesPanel.gd index 53f83d2e4..775074c0f 100644 --- a/src/UI/ReferenceImages/ReferencesPanel.gd +++ b/src/UI/ReferenceImages/ReferencesPanel.gd @@ -6,7 +6,12 @@ var reference_image_button_tscn := preload("res://src/UI/ReferenceImages/Referen @onready var list = $"Scroll/List" -func project_changed(): +func _ready() -> void: + Global.project_changed.connect(_update_reference_images) + OpenSave.reference_image_imported.connect(_update_reference_images) + + +func _update_reference_images(): for c in list.get_children(): c.queue_free() # Just do this here because I'm not sure where it's done.