diff --git a/src/Autoload/ExtensionsAPI.gd b/src/Autoload/ExtensionsAPI.gd index fb921e82e..6644a90fd 100644 --- a/src/Autoload/ExtensionsAPI.gd +++ b/src/Autoload/ExtensionsAPI.gd @@ -94,7 +94,7 @@ class GeneralAPI: func get_drawing_algos() -> DrawingAlgos: return DrawingAlgos - func get_shader_image_effect() -> ShaderImageEffect: + func get_new_shader_image_effect() -> ShaderImageEffect: return ShaderImageEffect.new() func get_extensions_node() -> Node: @@ -549,37 +549,77 @@ class SignalsAPI: func _on_texture_changed(): texture_changed.emit() - # Global signals - func connect_project_changed(target: Object, method: String): - Global.project_changed.connect(Callable(target, method)) + # GLOBAL SIGNALS + # pixelorama_opened + func connect_pixelorama_opened(callable: Callable): + Global.pixelorama_opened.connect(callable) + ExtensionsApi.add_action("pixelorama_opened") + + func disconnect_pixelorama_opened(callable: Callable): + Global.pixelorama_opened.disconnect(callable) + ExtensionsApi.remove_action("pixelorama_opened") + + # pixelorama_about_to_close + func connect_pixelorama_about_to_close(callable: Callable): + Global.pixelorama_about_to_close.connect(callable) + ExtensionsApi.add_action("pixelorama_about_to_close") + + func disconnect_pixelorama_about_to_close(callable: Callable): + Global.pixelorama_about_to_close.disconnect(callable) + ExtensionsApi.remove_action("pixelorama_about_to_close") + + # project_created -> signal has argument of type "Project" + func connect_project_created(callable: Callable): + Global.project_created.connect(callable) + ExtensionsApi.add_action("project_created") + + func disconnect_project_created(callable: Callable): + Global.project_created.disconnect(callable) + ExtensionsApi.remove_action("project_created") + + # project_saved + func connect_project_about_to_save(callable: Callable): + Global.project_saved.connect(callable) + ExtensionsApi.add_action("project_saved") + + func disconnect_project_saved(callable: Callable): + Global.project_saved.disconnect(callable) + ExtensionsApi.remove_action("project_saved") + + # project_changed + func connect_project_changed(callable: Callable): + Global.project_changed.connect(callable) ExtensionsApi.add_action("project_changed") - func disconnect_project_changed(target: Object, method: String): - Global.project_changed.disconnect(Callable(target, method)) + func disconnect_project_changed(callable: Callable): + Global.project_changed.disconnect(callable) ExtensionsApi.remove_action("project_changed") - func connect_cel_changed(target: Object, method: String): - Global.cel_changed.connect(Callable(target, method)) + # cel_changed + func connect_cel_changed(callable: Callable): + Global.cel_changed.connect(callable) ExtensionsApi.add_action("cel_changed") - func disconnect_cel_changed(target: Object, method: String): - Global.cel_changed.disconnect(Callable(target, method)) + func disconnect_cel_changed(callable: Callable): + Global.cel_changed.disconnect(callable) ExtensionsApi.remove_action("cel_changed") - # Tool Signal - func connect_tool_color_changed(target: Object, method: String): - Tools.color_changed.connect(Callable(target, method)) + # TOOL SIGNALs + # cel_changed + func connect_tool_color_changed(callable: Callable): + Tools.color_changed.connect(callable) ExtensionsApi.add_action("color_changed") - func disconnect_tool_color_changed(target: Object, method: String): - Tools.color_changed.disconnect(Callable(target, method)) + func disconnect_tool_color_changed(callable: Callable): + Tools.color_changed.disconnect(callable) ExtensionsApi.remove_action("color_changed") - # updater signals - func connect_current_cel_texture_changed(target: Object, method: String): - texture_changed.connect(Callable(target, method)) + # UPDATER SIGNALS + # current_cel_texture_changed + func connect_current_cel_texture_changed(callable: Callable): + texture_changed.connect(callable) ExtensionsApi.add_action("texture_changed") - func disconnect_current_cel_texture_changed(target: Object, method: String): - texture_changed.disconnect(Callable(target, method)) + func disconnect_current_cel_texture_changed(callable: Callable): + texture_changed.disconnect(callable) ExtensionsApi.remove_action("texture_changed") diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index c8bef40a2..2907ca4db 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -1,5 +1,8 @@ extends Node +signal pixelorama_opened +signal pixelorama_about_to_close +signal project_created(Project) signal project_changed signal cel_changed diff --git a/src/Autoload/OpenSave.gd b/src/Autoload/OpenSave.gd index 582b08e8c..a69982fa4 100644 --- a/src/Autoload/OpenSave.gd +++ b/src/Autoload/OpenSave.gd @@ -1,6 +1,8 @@ # gdlint: ignore=max-public-methods extends Node +signal project_saved + var current_save_paths: PackedStringArray = [] ## Stores a filename of a backup file in user:// until user saves manually var backup_save_paths: PackedStringArray = [] @@ -301,6 +303,7 @@ func save_pxo_file( Global.top_menu_container.file_menu.set_item_text( Global.FileMenu.SAVE, tr("Save") + " %s" % path.get_file() ) + project_saved.emit() save_project_to_recent_list(path) return true diff --git a/src/Classes/Project.gd b/src/Classes/Project.gd index 3a3caf565..f4766c24f 100644 --- a/src/Classes/Project.gd +++ b/src/Classes/Project.gd @@ -3,6 +3,9 @@ class_name Project extends RefCounted ## A class for project properties. +signal serialized(Dictionary) +signal about_to_deserialize(Dictionary) + var name := "": set(value): name = value @@ -102,6 +105,7 @@ func _init(_frames: Array[Frame] = [], _name := tr("untitled"), _size := Vector2 directory_path = Global.config_cache.get_value( "data", "current_dir", OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP) ) + Global.project_created.emit(self) func remove() -> void: @@ -332,10 +336,12 @@ func serialize() -> Dictionary: "metadata": metadata } + serialized.emit(project_data) return project_data func deserialize(dict: Dictionary) -> void: + about_to_deserialize.emit(dict) if dict.has("size_x") and dict.has("size_y"): size.x = dict.size_x size.y = dict.size_y diff --git a/src/Main.gd b/src/Main.gd index f1dfe9abe..4ec94fd14 100644 --- a/src/Main.gd +++ b/src/Main.gd @@ -67,6 +67,7 @@ func _ready() -> void: OS.request_permissions() _show_splash_screen() + Global.pixelorama_opened.emit() func _input(event: InputEvent) -> void: @@ -348,6 +349,7 @@ func _on_QuitAndSaveDialog_confirmed() -> void: func _quit() -> void: + Global.pixelorama_about_to_close.emit() # Darken the UI to denote that the application is currently exiting # (it won't respond to user input in this state). modulate = Color(0.5, 0.5, 0.5)