Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 35 additions & 6 deletions docs/godot/leaderboards.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ Since a player can have many aliases, you can use the `player_id` option to fetc

```gdscript
var options := Talo.leaderboards.GetEntriesOptions.new()
options.page = page
options.player_id = Talo.current_player.id

var res := await Talo.leaderboards.get_entries(internal_name, options)
Expand All @@ -110,12 +109,20 @@ If you want to scope entries to a specific alias instead, use the `alias_id` opt

```gdscript
var options := Talo.leaderboards.GetEntriesOptions.new()
options.page = page
options.alias_id = Talo.current_alias.id

var res := await Talo.leaderboards.get_entries(internal_name, options)
```

You can also filter entries by the service an alias belongs to using the `alias_service` option:

```gdscript
var options := Talo.leaderboards.GetEntriesOptions.new()
options.alias_service = "steam"

var res := await Talo.leaderboards.get_entries(internal_name, options)
```

### Getting archived entries

If your leaderboard uses refresh intervals (i.e. daily, weekly, monthly, yearly), you can get archived entries using the `include_archived` option:
Expand All @@ -131,11 +138,33 @@ var res := await Talo.leaderboards.get_entries(internal_name, options)

After fetching your leaderboard entries you can take advantage of the internal cache to construct your UI, removing the need for any subsequent network requests.

You can use `Talo.leaderboards.get_cached_entries()` in the same way as `get_entries()` above. Every entry fetched previously using `get_entries()` will exist in the cache. The same logic applies for entries fetched with `alias_id` set, using `get_cached_entries_for_current_player()`.
You can use `Talo.leaderboards.get_cached_entries()` in the same way as `get_entries()` above. Every entry fetched previously using `get_entries()` will exist in the cache.

:::caution
`player_id` is not supported by `get_cached_entries_for_current_player()`.
:::
`get_cached_entries()` also accepts an optional `GetCachedEntriesOptions` object to filter the cached results client-side:

```gdscript
# Filter cached entries by player
var options := Talo.leaderboards.GetCachedEntriesOptions.new()
options.player_id = Talo.current_player.id

var entries := Talo.leaderboards.get_cached_entries(internal_name, options)
```

```gdscript
# Filter cached entries by alias
var options := Talo.leaderboards.GetCachedEntriesOptions.new()
options.alias_id = Talo.current_alias.id

var entries := Talo.leaderboards.get_cached_entries(internal_name, options)
```

```gdscript
# Filter cached entries by alias service
var options := Talo.leaderboards.GetCachedEntriesOptions.new()
options.alias_service = "steam"

var entries := Talo.leaderboards.get_cached_entries(internal_name, options)
```

Similarly, updated results from `add_entry()` will also be reflected in the cache - the entry returned from the response will be upserted and the positions of the other entries in the cache will be updated.

Expand Down
37 changes: 31 additions & 6 deletions docs/unity/leaderboards.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ Since a player can have many aliases, you can use the `playerId` option to fetch

```csharp
var entries = await Talo.Leaderboards.GetEntries(internalName, new GetEntriesOptions() {
page = page,
playerId = Talo.CurrentPlayer.id
});
```
Expand All @@ -120,11 +119,18 @@ If you want to scope entries to a specific alias instead, use the `aliasId` opti

```csharp
var entries = await Talo.Leaderboards.GetEntries(internalName, new GetEntriesOptions() {
page = page,
aliasId = Talo.CurrentAlias.id
});
```

You can also filter entries by the service an alias belongs to using the `aliasService` option:

```csharp
var entries = await Talo.Leaderboards.GetEntries(internalName, new GetEntriesOptions() {
aliasService = "steam"
});
```

### Getting archived entries

If your leaderboard uses refresh intervals (i.e. daily, weekly, monthly, yearly), you can get archived entries using the `includeArchived` option:
Expand All @@ -140,11 +146,30 @@ var entries = await Talo.Leaderboards.GetEntries(internalName, new GetEntriesOpt

After fetching your leaderboard entries you can take advantage of the internal cache to construct your UI, removing the need for any subsequent network requests.

You can use `Talo.Leaderboard.GetCachedEntries()` in the same way as `GetEntries()` above. Every entry fetched previously using `GetEntries()` will exist in the cache. The same logic applies for entries fetched with `aliasId` set, using `GetCachedEntriesForCurrentPlayer()`.
You can use `Talo.Leaderboard.GetCachedEntries()` in the same way as `GetEntries()` above. Every entry fetched previously using `GetEntries()` will exist in the cache.

:::caution
`playerId` is not supported by `GetCachedEntriesForCurrentPlayer()`.
:::
`GetCachedEntries()` also accepts an optional `GetCachedEntriesOptions` object to filter the cached results client-side:

```csharp
// Filter cached entries by player
var entries = Talo.Leaderboards.GetCachedEntries(internalName, new GetCachedEntriesOptions() {
playerId = Talo.CurrentPlayer.id
});
```

```csharp
// Filter cached entries by alias
var entries = Talo.Leaderboards.GetCachedEntries(internalName, new GetCachedEntriesOptions() {
aliasId = Talo.CurrentAlias.id
});
```

```csharp
// Filter cached entries by alias service
var entries = Talo.Leaderboards.GetCachedEntries(internalName, new GetCachedEntriesOptions() {
aliasService = "steam"
});
```

Similarly, updated results from `AddEntry()` will also be reflected in the cache - the entry returned from the response will be upserted and the positions of the other entries in the cache will be updated.

Expand Down