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/demo/project.godot b/plugin/demo/project.godot index 24e4d51..15b9f1a 100644 --- a/plugin/demo/project.godot +++ b/plugin/demo/project.godot @@ -20,25 +20,12 @@ run/main_scene="res://scenes/MainMenu.tscn" config/features=PackedStringArray("4.2", "Mobile") config/icon="res://icon.svg" -[autoload] - -GodotPlayGameServices="*res://addons/GodotPlayGameServices/autoloads/godot_play_game_services.gd" -SignInClient="*res://addons/GodotPlayGameServices/autoloads/sign_in_client.gd" -AchievementsClient="*res://addons/GodotPlayGameServices/autoloads/achievements_client.gd" -LeaderboardsClient="*res://addons/GodotPlayGameServices/autoloads/leaderboards_client.gd" -PlayersClient="*res://addons/GodotPlayGameServices/autoloads/players_client.gd" -SnapshotsClient="*res://addons/GodotPlayGameServices/autoloads/snapshots_client.gd" - [display] window/size/viewport_width=720 window/size/viewport_height=1280 window/handheld/orientation=1 -[editor_plugins] - -enabled=PackedStringArray("res://addons/GodotPlayGameServices/plugin.cfg") - [file_customization] folder_colors={ 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.