From f013a7818085c1d3616a590c36f5d873dc26720d Mon Sep 17 00:00:00 2001 From: Variable Date: Sat, 9 Nov 2024 00:15:08 +0500 Subject: [PATCH 1/2] add autoloads to api --- src/Autoload/ExtensionsApi.gd | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Autoload/ExtensionsApi.gd b/src/Autoload/ExtensionsApi.gd index 3b4faaaba..3833300cf 100644 --- a/src/Autoload/ExtensionsApi.gd +++ b/src/Autoload/ExtensionsApi.gd @@ -381,6 +381,10 @@ class PanelAPI: ## Gives access to theme related functions. class ThemeAPI: + ## Returns the Themes autoload. Allows interacting with themes on a more deeper level. + func get_autoload() -> Themes: + return Themes + ## Adds the [param theme] to [code]Edit -> Preferences -> Interface -> Themes[/code]. func add_theme(theme: Theme) -> void: Themes.add_theme(theme) @@ -438,6 +442,10 @@ class ToolAPI: # gdlint: ignore=constant-name const LayerTypes := Global.LayerTypes + ## Returns the Tools autoload. Allows interacting with tools on a more deeper level. + func get_autoload() -> Tools: + return Tools + ## Adds a tool to pixelorama with name [param tool_name] (without spaces), ## display name [param display_name], tool scene [param scene], layers that the tool works ## on [param layer_types] defined by [constant LayerTypes], @@ -678,6 +686,11 @@ class ExportAPI: # gdlint: ignore=constant-name const ExportTab := Export.ExportTab + ## Returns the Export autoload. + ## Allows interacting with the export workflow on a more deeper level. + func get_autoload() -> Export: + return Export + ## [param format_info] has keys: [code]extension[/code] and [code]description[/code] ## whose values are of type [String] e.g:[codeblock] ## format_info = {"extension": ".gif", "description": "GIF Image"} @@ -730,6 +743,11 @@ class ExportAPI: ## Gives access to adding custom import options. class ImportAPI: + ## Returns the OpenSave autoload. Contains code to handle file loading. + ## It also contains code to handle project saving (.pxo) + func get_autoload() -> OpenSave: + return OpenSave + ## [param import_scene] is a scene preload that will be instanced and added to "import options" ## section of pixelorama's import dialogs and will appear whenever [param import_name] is ## chosen from import menu. @@ -757,6 +775,10 @@ class ImportAPI: ## Gives access to palette related stuff. class PaletteAPI: + ## Returns the Palettes autoload. Allows interacting with palettes on a more deeper level. + func get_autoload() -> Palettes: + return Palettes + ## Creates and adds a new [Palette] with name [param palette_name] containing [param data]. ## [param data] is a [Dictionary] containing the palette information. ## An example of [code]data[/code] will be:[codeblock] From aabbb9a95fa0e3726d75ff77653dd65b167743ce Mon Sep 17 00:00:00 2001 From: Variable Date: Sat, 9 Nov 2024 00:53:01 +0500 Subject: [PATCH 2/2] A name Dilemma, There are 2 autoloads for ImportApi --- src/Autoload/ExtensionsApi.gd | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Autoload/ExtensionsApi.gd b/src/Autoload/ExtensionsApi.gd index 3833300cf..871fe3ef9 100644 --- a/src/Autoload/ExtensionsApi.gd +++ b/src/Autoload/ExtensionsApi.gd @@ -382,7 +382,7 @@ class PanelAPI: ## Gives access to theme related functions. class ThemeAPI: ## Returns the Themes autoload. Allows interacting with themes on a more deeper level. - func get_autoload() -> Themes: + func autoload() -> Themes: return Themes ## Adds the [param theme] to [code]Edit -> Preferences -> Interface -> Themes[/code]. @@ -443,7 +443,7 @@ class ToolAPI: const LayerTypes := Global.LayerTypes ## Returns the Tools autoload. Allows interacting with tools on a more deeper level. - func get_autoload() -> Tools: + func autoload() -> Tools: return Tools ## Adds a tool to pixelorama with name [param tool_name] (without spaces), @@ -688,7 +688,7 @@ class ExportAPI: ## Returns the Export autoload. ## Allows interacting with the export workflow on a more deeper level. - func get_autoload() -> Export: + func autoload() -> Export: return Export ## [param format_info] has keys: [code]extension[/code] and [code]description[/code] @@ -745,9 +745,12 @@ class ExportAPI: class ImportAPI: ## Returns the OpenSave autoload. Contains code to handle file loading. ## It also contains code to handle project saving (.pxo) - func get_autoload() -> OpenSave: + func open_save_autoload() -> OpenSave: return OpenSave + func import_autoload() -> Import: + return Import + ## [param import_scene] is a scene preload that will be instanced and added to "import options" ## section of pixelorama's import dialogs and will appear whenever [param import_name] is ## chosen from import menu. @@ -776,7 +779,7 @@ class ImportAPI: ## Gives access to palette related stuff. class PaletteAPI: ## Returns the Palettes autoload. Allows interacting with palettes on a more deeper level. - func get_autoload() -> Palettes: + func autoload() -> Palettes: return Palettes ## Creates and adds a new [Palette] with name [param palette_name] containing [param data].