From 00ce25a704cb903ce9ff01305e1b97ce02211e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20Ib=C3=A1=C3=B1ez=20S=C3=A1nchez?= Date: Thu, 29 Feb 2024 14:02:18 +0100 Subject: [PATCH] Change load order of autoloads to avoid dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jacob Ibáñez Sánchez --- CHANGELOG.md | 4 ++++ .../autoloads/achievements_client.gd | 1 - .../autoloads/godot_play_game_services.gd | 1 - .../autoloads/leaderboards_client.gd | 1 - .../autoloads/players_client.gd | 1 - .../autoloads/sign_in_client.gd | 1 - .../autoloads/snapshots_client.gd | 1 - plugin/export_scripts_template/export_plugin.gd | 13 ++++++++----- .../marshalling/json_marshaller.gd | 3 +-- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a11c0b..26ea13e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v1.5.0 +### Order of autoloads +The autoloads where causing errors on first launch of the project, due to the load order and dependencies between them. The load order has now been fixed to avoid this errors. + ## v1.4.0 ### Increase max length of Game ID In the new dock that the plugin adds to the bottom bar, the max length of the Game ID has been increased from 12 to 20 characters. diff --git a/plugin/export_scripts_template/autoloads/achievements_client.gd b/plugin/export_scripts_template/autoloads/achievements_client.gd index 507d7af..80b45aa 100644 --- a/plugin/export_scripts_template/autoloads/achievements_client.gd +++ b/plugin/export_scripts_template/autoloads/achievements_client.gd @@ -1,4 +1,3 @@ -class_name PlayGamesAchievementsClient extends Node ## Client with achievements functionality. ## diff --git a/plugin/export_scripts_template/autoloads/godot_play_game_services.gd b/plugin/export_scripts_template/autoloads/godot_play_game_services.gd index 94e1a74..ad758b3 100644 --- a/plugin/export_scripts_template/autoloads/godot_play_game_services.gd +++ b/plugin/export_scripts_template/autoloads/godot_play_game_services.gd @@ -1,4 +1,3 @@ -class_name PlayGamesEntryPoint extends Node ## Main Autoload of the plugin, which contains a reference to the android plugin itself. ## diff --git a/plugin/export_scripts_template/autoloads/leaderboards_client.gd b/plugin/export_scripts_template/autoloads/leaderboards_client.gd index db1a38a..8f706b7 100644 --- a/plugin/export_scripts_template/autoloads/leaderboards_client.gd +++ b/plugin/export_scripts_template/autoloads/leaderboards_client.gd @@ -1,4 +1,3 @@ -class_name PlayGamesLeaderboardsClient extends Node ## Client with leaderboards functionality. ## diff --git a/plugin/export_scripts_template/autoloads/players_client.gd b/plugin/export_scripts_template/autoloads/players_client.gd index d5f2a28..f957df1 100644 --- a/plugin/export_scripts_template/autoloads/players_client.gd +++ b/plugin/export_scripts_template/autoloads/players_client.gd @@ -1,4 +1,3 @@ -class_name PlayGamesPlayersClient extends Node ## Client with player functionality. ## diff --git a/plugin/export_scripts_template/autoloads/sign_in_client.gd b/plugin/export_scripts_template/autoloads/sign_in_client.gd index 3be0f55..f9928c5 100644 --- a/plugin/export_scripts_template/autoloads/sign_in_client.gd +++ b/plugin/export_scripts_template/autoloads/sign_in_client.gd @@ -1,4 +1,3 @@ -class_name PlayGamesSignInClient extends Node ## Client with sign in functionality. ## diff --git a/plugin/export_scripts_template/autoloads/snapshots_client.gd b/plugin/export_scripts_template/autoloads/snapshots_client.gd index 6b2bf1e..ab8ebce 100644 --- a/plugin/export_scripts_template/autoloads/snapshots_client.gd +++ b/plugin/export_scripts_template/autoloads/snapshots_client.gd @@ -1,4 +1,3 @@ -class_name PlayGamesSnapshotsClient extends Node ## Client with save and load games functionality. ## diff --git a/plugin/export_scripts_template/export_plugin.gd b/plugin/export_scripts_template/export_plugin.gd index 9a89563..dd97676 100644 --- a/plugin/export_scripts_template/export_plugin.gd +++ b/plugin/export_scripts_template/export_plugin.gd @@ -1,6 +1,7 @@ @tool extends EditorPlugin +const JSON_MARSHALLER_SCRIPT := "res://addons/GodotPlayGameServices/marshalling/json_marshaller.gd" const PLUGIN_AUTOLOAD := "GodotPlayGameServices" const SIGN_IN_AUTOLOAD := "SignInClient" const ACHIEVEMENTS_AUTOLOAD := "AchievementsClient" @@ -12,6 +13,7 @@ var _export_plugin : AndroidExportPlugin var _dock : Node func _enter_tree(): + add_custom_type("JsonMarshaller", "RefCounted", preload(JSON_MARSHALLER_SCRIPT), null) _add_plugin() _add_docks() _add_autoloads() @@ -20,6 +22,7 @@ func _exit_tree(): _remove_plugin() _remove_docks() _remove_autoloads() + remove_custom_type("JsonMarshaller") func _add_plugin() -> void: _export_plugin = AndroidExportPlugin.new() @@ -41,18 +44,18 @@ func _remove_docks() -> void: func _add_autoloads() -> void: add_autoload_singleton(PLUGIN_AUTOLOAD, "res://addons/GodotPlayGameServices/autoloads/godot_play_game_services.gd") add_autoload_singleton(SIGN_IN_AUTOLOAD, "res://addons/GodotPlayGameServices/autoloads/sign_in_client.gd") + add_autoload_singleton(PLAYERS_AUTOLOAD, "res://addons/GodotPlayGameServices/autoloads/players_client.gd") add_autoload_singleton(ACHIEVEMENTS_AUTOLOAD, "res://addons/GodotPlayGameServices/autoloads/achievements_client.gd") add_autoload_singleton(LEADERBOARDS_AUTOLOAD, "res://addons/GodotPlayGameServices/autoloads/leaderboards_client.gd") - add_autoload_singleton(PLAYERS_AUTOLOAD, "res://addons/GodotPlayGameServices/autoloads/players_client.gd") add_autoload_singleton(SNAPSHOTS_AUTOLOAD, "res://addons/GodotPlayGameServices/autoloads/snapshots_client.gd") func _remove_autoloads() -> void: - remove_autoload_singleton(PLUGIN_AUTOLOAD) - remove_autoload_singleton(SIGN_IN_AUTOLOAD) - remove_autoload_singleton(ACHIEVEMENTS_AUTOLOAD) + remove_autoload_singleton(SNAPSHOTS_AUTOLOAD) remove_autoload_singleton(LEADERBOARDS_AUTOLOAD) + remove_autoload_singleton(ACHIEVEMENTS_AUTOLOAD) remove_autoload_singleton(PLAYERS_AUTOLOAD) - remove_autoload_singleton(SNAPSHOTS_AUTOLOAD) + remove_autoload_singleton(SIGN_IN_AUTOLOAD) + remove_autoload_singleton(PLUGIN_AUTOLOAD) class AndroidExportPlugin extends EditorExportPlugin: var _plugin_name = "GodotPlayGameServices" diff --git a/plugin/export_scripts_template/marshalling/json_marshaller.gd b/plugin/export_scripts_template/marshalling/json_marshaller.gd index e2ff0ff..03b3bf6 100644 --- a/plugin/export_scripts_template/marshalling/json_marshaller.gd +++ b/plugin/export_scripts_template/marshalling/json_marshaller.gd @@ -1,5 +1,4 @@ -class_name JsonMarshaller -extends Object +class_name JsonMarshaller extends RefCounted ## A Class for encapsulating JSON parsing ## ## This class exposes methods to parse JSON arrays and dictionaries.