Skip to content

Commit 9cdff0c

Browse files
authored
Merge pull request #68 from TaloDev/develop
Release 0.21.0
2 parents 494ca10 + 8817d54 commit 9cdff0c

File tree

14 files changed

+107
-19
lines changed

14 files changed

+107
-19
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ The Talo Godot Plugin is a lightweight wrapper around the [REST API](https://doc
1919
- 🕹️ [Leaderboards](https://trytalo.com/leaderboards): Highly customisable leaderboards that can sync with Steamworks.
2020
- 💾 [Game saves](https://trytalo.com/saves): A simple and flexible way to load/save game state; also works offline.
2121
- 📊 [Game stats](https://trytalo.com/stats): Track global or per-player stats across your game; also syncs with Steamworks.
22-
- 💬 [Game channels](https://trytalo.com/channels): Send real-time messages between players subscribed to specific topics.
22+
- 💬 [Game
23+
channels](https://trytalo.com/channels): Send real-time messages between players subscribed to specific topics.
2324
- ⚙️ [Live config](https://trytalo.com/live-config): Update game settings from the web with zero downtime.
2425
- 🔧 [Steamworks integration](https://trytalo.com/steamworks-integration): Hook into Steamworks for authentication and ownership checks.
2526
- 🗣️ [Game feedback](https://trytalo.com/feedback): Collect and manage feedback from your players.
2627
- 🛡️ [Continuity](https://trytalo.com/continuity): Keep your data in-sync even when your players are offline.
28+
- 🔔 [Player presence](https://trytalo.com/player#presence): See if players are online and set custom statuses.
2729

2830
## Samples included with the plugin
2931

addons/talo/apis/channels_api.gd

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ class_name ChannelsAPI extends TaloAPI
55
##
66
## @tutorial: https://docs.trytalo.com/docs/godot/channels
77

8+
## Emitted when a message is received from a channel.
9+
signal message_received(channel: TaloChannel, player_alias: TaloPlayerAlias, message: String)
10+
11+
func _ready():
12+
await Talo.init_completed
13+
Talo.socket.message_received.connect(_on_message_received)
14+
15+
func _on_message_received(res: String, data: Dictionary) -> void:
16+
if res == "v1.channels.message":
17+
message_received.emit(TaloChannel.new(data.channel), TaloPlayerAlias.new(data.playerAlias), data.message)
18+
819
## Get a channel by its ID.
920
func find(channel_id: int) -> TaloChannel:
1021
var res = await client.make_request(HTTPClient.METHOD_GET, "/%s" % channel_id)
@@ -111,7 +122,7 @@ func delete(channel_id: int) -> void:
111122
return
112123

113124
var res = await client.make_request(HTTPClient.METHOD_DELETE, "/%s" % channel_id)
114-
125+
115126
match (res.status):
116127
403:
117128
push_error("Player does not have permissions to delete channel %s." % channel_id)

addons/talo/apis/game_config_api.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ class_name GameConfigAPI extends TaloAPI
77

88
## Emitted when the live config has been loaded.
99
signal live_config_loaded(live_config: TaloLiveConfig)
10+
11+
## Emitted when the live config has been updated.
1012
signal live_config_updated(live_config: TaloLiveConfig)
1113

1214
func _ready() -> void:

addons/talo/apis/leaderboards_api.gd

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@ func get_cached_entries_for_current_player(internal_name: String) -> Array:
2222
)
2323

2424
## Get a list of entries for a leaderboard. The page parameter is used for pagination.
25-
func get_entries(internal_name: String, page: int, alias_id = -1) -> Array:
25+
func get_entries(internal_name: String, page: int, alias_id = -1, include_archived = false) -> Array:
2626
var url = "/%s/entries?page=%s"
2727
var url_data = [internal_name, page]
2828

2929
if alias_id != -1:
3030
url += "&aliasId=%s"
3131
url_data += alias_id
3232

33+
if include_archived:
34+
url += "&withDeleted=1"
35+
3336
var res = await client.make_request(HTTPClient.METHOD_GET, url % url_data)
3437

3538
match (res.status):
@@ -46,11 +49,11 @@ func get_entries(internal_name: String, page: int, alias_id = -1) -> Array:
4649
return []
4750

4851
## Get a list of entries for a leaderboard for the current player. The page parameter is used for pagination.
49-
func get_entries_for_current_player(internal_name: String, page: int) -> Array:
52+
func get_entries_for_current_player(internal_name: String, page: int, include_archived = false) -> Array:
5053
if Talo.identity_check() != OK:
5154
return []
52-
53-
return await get_entries(internal_name, page, Talo.current_alias.id)
55+
56+
return await get_entries(internal_name, page, Talo.current_alias.id, include_archived)
5457

5558
## Add an entry to a leaderboard. The props (key-value pairs) parameter is used to store additional data with the entry.
5659
func add_entry(internal_name: String, score: float, props: Dictionary = {}) -> Array:
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
class_name PlayerPresenceAPI extends TaloAPI
2+
## An interface for communicating with the Talo Player Presence API.
3+
##
4+
## This API is used to track and manage player presence in your game. Presence indicates whether players are online
5+
## and their current status.
6+
##
7+
## @tutorial: https://docs.trytalo.com/docs/godot/player-presence
8+
9+
## Emitted when a player's presence status changes.
10+
signal presence_changed(presence: TaloPlayerPresence, online_changed: bool, custom_status_changed: bool)
11+
12+
func _ready():
13+
await Talo.init_completed
14+
Talo.socket.message_received.connect(_on_message_received)
15+
16+
func _on_message_received(res: String, data: Dictionary) -> void:
17+
if res == "v1.players.presence.updated":
18+
presence_changed.emit(TaloPlayerPresence.new(data.presence), data.meta.onlineChanged, data.meta.customStatusChanged)
19+
20+
## Get the presence status for a specific player.
21+
func get_presence(player_id: String) -> TaloPlayerPresence:
22+
var res = await client.make_request(HTTPClient.METHOD_GET, "/%s" % player_id)
23+
24+
match (res.status):
25+
200:
26+
return TaloPlayerPresence.new(res.body.presence)
27+
_:
28+
return null
29+
30+
## Update the presence status for the current player.
31+
func update_presence(online: bool, custom_status: String = "") -> TaloPlayerPresence:
32+
if Talo.identity_check() != OK:
33+
return null
34+
35+
var res = await client.make_request(HTTPClient.METHOD_PUT, "", {
36+
online = online,
37+
customStatus = custom_status
38+
})
39+
40+
match (res.status):
41+
200:
42+
return TaloPlayerPresence.new(res.body.presence)
43+
_:
44+
return null

addons/talo/entities/channel.gd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ func _init(data: Dictionary):
1313

1414
id = data.id
1515
display_name = data.name
16-
owner_alias = TaloPlayerAlias.new(data.owner)
16+
if data.owner:
17+
owner_alias = TaloPlayerAlias.new(data.owner)
1718
total_messages = data.totalMessages
18-
member_count = data.memberCount
19+
member_count = data.get('memberCount', 0) # TODO: socket messages don't currently send the memberCount
1920
created_at = data.createdAt
2021
updated_at = data.updatedAt

addons/talo/entities/leaderboard_entry.gd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var score: float
66
var player_alias: TaloPlayerAlias
77
var created_at: String
88
var updated_at: String
9+
var deleted_at: String
910

1011
func _init(data: Dictionary):
1112
super._init(data.props.map(func (prop): return TaloProp.new(prop.key, prop.value)))
@@ -16,3 +17,5 @@ func _init(data: Dictionary):
1617
player_alias = TaloPlayerAlias.new(data.playerAlias)
1718
created_at = data.createdAt
1819
updated_at = data.updatedAt
20+
if data.deletedAt:
21+
deleted_at = data.deletedAt

addons/talo/entities/live_config.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ func _init(props: Array):
1111
## Get a property value by key. Returns the fallback value if the key is not found.
1212
func get_prop(key: String, fallback: String) -> String:
1313
var filtered = props.filter(func (prop: TaloProp): return prop.key == key)
14-
return fallback if filtered.is_empty() else filtered.front()
14+
return fallback if filtered.is_empty() else filtered.front().value
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class_name TaloPlayerPresence extends Node
2+
3+
var online: bool
4+
var custom_status: String
5+
var player_alias: TaloPlayerAlias
6+
var updated_at: String
7+
8+
func _init(data: Dictionary):
9+
online = data.online
10+
custom_status = data.customStatus
11+
player_alias = null if data.playerAlias == null else TaloPlayerAlias.new(data.playerAlias)
12+
updated_at = data.updatedAt

addons/talo/plugin.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[plugin]
22

33
name="Talo Game Services"
4-
description="Talo (https://trytalo.com) is an open-source game backend with services designed to help you build games faster. You can currently:\n\n- Identify and authenticate players\n- Store persistent data across players\n- Track events (levelling up, finding loot, etc)\n- Display high scores with leaderboards\n- Store and load player saves\n- Load game config options and flags from the cloud\n- Get feedback directly from your players\n- Keep your data in-sync even when players are offline\n- Send channel messages between players"
4+
description="Talo (https://trytalo.com) is an open-source game backend with services designed to help you build games faster. You can currently:\n\n- Identify and authenticate players\n- Store persistent data across players\n- Track events (levelling up, finding loot, etc)\n- Display high scores with leaderboards\n- Store and load player saves\n- Load game config options and flags from the cloud\n- Get feedback directly from your players\n- Keep your data in-sync even when players are offline\n- Send channel messages between players\n- See if players are online and set custom statuses"
55
author="trytalo"
6-
version="0.20.0"
6+
version="0.21.0"
77
script="talo_autoload.gd"

0 commit comments

Comments
 (0)