diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d074f3..0759c84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v1.7.0 +### Send JSON strings instead of Dictionaries +The `gameLoaded` and `conflictEmitted` signals where sending an instance of the Dictionary class. Instead, they send a JSON string now, as suggested by @nepalisameer in [this issue](https://github.com/Iakobs/godot-play-game-services/issues/22). + ## v1.6.0 ### Load Snapshots The [loadPlayerCenteredScores](https://developers.google.com/android/reference/com/google/android/gms/games/SnapshotsClient#load(boolean)) method from Google's API has been added, returning the list of Snapshots for the current signed in player. diff --git a/plugin/export_scripts_template/autoloads/snapshots_client.gd b/plugin/export_scripts_template/autoloads/snapshots_client.gd index 9b2446b..981bf27 100644 --- a/plugin/export_scripts_template/autoloads/snapshots_client.gd +++ b/plugin/export_scripts_template/autoloads/snapshots_client.gd @@ -36,11 +36,13 @@ func _ready() -> void: func(is_saved: bool, save_data_name: String, save_data_description: String): game_saved.emit(is_saved, save_data_name, save_data_description) ) - GodotPlayGameServices.android_plugin.gameLoaded.connect(func(dictionary: Dictionary): - game_loaded.emit(Snapshot.new(dictionary)) + GodotPlayGameServices.android_plugin.gameLoaded.connect(func(json_data: String): + var safe_dictionary := GodotPlayGameServices.json_marshaller.safe_parse_dictionary(json_data) + game_loaded.emit(Snapshot.new(safe_dictionary)) ) - GodotPlayGameServices.android_plugin.conflictEmitted.connect(func(dictionary: Dictionary): - conflict_emitted.emit(SnapshotConflict.new(dictionary)) + GodotPlayGameServices.android_plugin.conflictEmitted.connect(func(json_data: String): + var safe_dictionary := GodotPlayGameServices.json_marshaller.safe_parse_dictionary(json_data) + conflict_emitted.emit(SnapshotConflict.new(safe_dictionary)) ) GodotPlayGameServices.android_plugin.snapshotsLoaded.connect(func(json_data: String): var safe_array := GodotPlayGameServices.json_marshaller.safe_parse_array(json_data) @@ -58,9 +60,9 @@ func _ready() -> void: ## [param allow_delete]: Whether or not to provide a delete overflow menu option for each snapshot in the selection UI.[br] ## [param max_snapshots]: The maximum number of snapshots to display in the UI. Use [constant DISPLAY_LIMIT_NONE] to display all snapshots. func show_saved_games( - title: String, - allow_add_button: bool, - allow_delete: bool, + title: String, + allow_add_button: bool, + allow_delete: bool, max_snapshots: int ) -> void: if GodotPlayGameServices.android_plugin: @@ -75,9 +77,9 @@ func show_saved_games( ## [param played_time_millis]: Optional. The played time of this snapshot in milliseconds.[br] ## [param progress_value]: Optional. The progress value for this snapshot. func save_game( - file_name: String, + file_name: String, description: String, - save_data: PackedByteArray, + save_data: PackedByteArray, played_time_millis: int = 0, progress_value: int = 0, ) -> void: diff --git a/plugin/export_scripts_template/plugin.cfg b/plugin/export_scripts_template/plugin.cfg index a5b2c65..dd9f617 100644 --- a/plugin/export_scripts_template/plugin.cfg +++ b/plugin/export_scripts_template/plugin.cfg @@ -3,5 +3,5 @@ name="GodotPlayGameServices" description="A Godot 4.2 plugin for Google Play Game Services" author="Jacob Ibáñez Sánchez" -version="1.5.0" +version="1.7.0" script="export_plugin.gd" diff --git a/plugin/src/main/java/com/jacobibanez/plugin/android/godotplaygameservices/signals/Signals.kt b/plugin/src/main/java/com/jacobibanez/plugin/android/godotplaygameservices/signals/Signals.kt index 2b72f16..9152154 100644 --- a/plugin/src/main/java/com/jacobibanez/plugin/android/godotplaygameservices/signals/Signals.kt +++ b/plugin/src/main/java/com/jacobibanez/plugin/android/godotplaygameservices/signals/Signals.kt @@ -188,14 +188,14 @@ object SnapshotSignals { * * @return A [Dictionary] representing a [com.google.android.gms.games.snapshot.Snapshot](https://developers.google.com/android/reference/com/google/android/gms/games/snapshot/Snapshot). */ - val gameLoaded = SignalInfo("gameLoaded", Dictionary::class.java) + val gameLoaded = SignalInfo("gameLoaded", String::class.java) /** * This signal is emitted when saving or loading a game, whenever a conflict occurs. * * @return A [Dictionary] representing a [com.google.android.gms.games.SnapshotsClient.SnapshotConflict](https://developers.google.com/android/reference/com/google/android/gms/games/SnapshotsClient.SnapshotConflict). */ - val conflictEmitted = SignalInfo("conflictEmitted", Dictionary::class.java) + val conflictEmitted = SignalInfo("conflictEmitted", String::class.java) /** * This signal is emitted when calling the [com.jacobibanez.plugin.android.godotplaygameservices.GodotAndroidPlugin.loadSnapshots] method. diff --git a/plugin/src/main/java/com/jacobibanez/plugin/android/godotplaygameservices/snapshots/SnapshotsProxy.kt b/plugin/src/main/java/com/jacobibanez/plugin/android/godotplaygameservices/snapshots/SnapshotsProxy.kt index 1cf19ce..7d0d0dc 100644 --- a/plugin/src/main/java/com/jacobibanez/plugin/android/godotplaygameservices/snapshots/SnapshotsProxy.kt +++ b/plugin/src/main/java/com/jacobibanez/plugin/android/godotplaygameservices/snapshots/SnapshotsProxy.kt @@ -108,7 +108,7 @@ class SnapshotsProxy( godot, GODOT_PLUGIN_NAME, gameLoaded, - fromSnapshot(godot, snapshot) + Gson().toJson(fromSnapshot(godot, snapshot)) ) } } else { @@ -199,7 +199,7 @@ class SnapshotsProxy( godot, GODOT_PLUGIN_NAME, conflictEmitted, - fromConflict(godot, it) + Gson().toJson(fromConflict(godot, it)) ) } }