Skip to content

Commit

Permalink
Add loadSnapshots method to the plugin
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 Mar 2, 2024
1 parent 43cdf5a commit fd87c99
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
### 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.

### Fix crash when loading non existing save game
When calling the `loadGame` method with a non existing file name, the app crashed. This is fixed now, the app just prints a log with the error and continues execution.

## 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. Also, the plugin is now disabled by default in the demo project. Look at the [demo project documentation](https://github.com/Iakobs/godot-play-game-services/tree/main/plugin/demo) for further info.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,25 +96,23 @@ class SnapshotsProxy(
fun loadGame(fileName: String) {
Log.d(tag, "Loading snapshot with name $fileName.")
snapshotsClient.open(fileName, false, RESOLUTION_POLICY_MOST_RECENTLY_MODIFIED)
.addOnFailureListener { exception ->
Log.e(tag, "Error while opening Snapshot $fileName for loading.", exception);
}.continueWith { task ->
val dataOrConflict = task.result
if (dataOrConflict.isConflict) {
handleConflict(dataOrConflict.conflict)
return@continueWith null
}
dataOrConflict.data?.let { snapshot ->
return@continueWith snapshot
}
}.addOnCompleteListener { task ->
task.result?.let { snapshot ->
emitSignal(
godot,
GODOT_PLUGIN_NAME,
gameLoaded,
fromSnapshot(godot, snapshot)
)
.addOnCompleteListener { task ->
if (task.isSuccessful) {
val dataOrConflict = task.result
if (dataOrConflict.isConflict) {
handleConflict(dataOrConflict.conflict)
return@addOnCompleteListener
}
dataOrConflict.data?.let { snapshot ->
emitSignal(
godot,
GODOT_PLUGIN_NAME,
gameLoaded,
fromSnapshot(godot, snapshot)
)
}
} else {
Log.e(tag, "Error while opening Snapshot $fileName for loading. Cause: ${task.exception}")
}
}
}
Expand Down

0 comments on commit fd87c99

Please sign in to comment.