Skip to content

Commit

Permalink
Change load order of autoloads to avoid dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Ibáñez Sánchez <jacobibanez@jacobibanez.com>
  • Loading branch information
Iakobs committed Feb 29, 2024
1 parent b726e24 commit 00ce25a
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
class_name PlayGamesAchievementsClient
extends Node
## Client with achievements functionality.
##
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
class_name PlayGamesEntryPoint
extends Node
## Main Autoload of the plugin, which contains a reference to the android plugin itself.
##
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
class_name PlayGamesLeaderboardsClient
extends Node
## Client with leaderboards functionality.
##
Expand Down
1 change: 0 additions & 1 deletion plugin/export_scripts_template/autoloads/players_client.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
class_name PlayGamesPlayersClient
extends Node
## Client with player functionality.
##
Expand Down
1 change: 0 additions & 1 deletion plugin/export_scripts_template/autoloads/sign_in_client.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
class_name PlayGamesSignInClient
extends Node
## Client with sign in functionality.
##
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
class_name PlayGamesSnapshotsClient
extends Node
## Client with save and load games functionality.
##
Expand Down
13 changes: 8 additions & 5 deletions plugin/export_scripts_template/export_plugin.gd
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit 00ce25a

Please sign in to comment.