Show public names in leaderboards
This commit is contained in:
1 parent
1b5b8dc0a4
commit
31ddba0d45
8 files changed
+98
-12
No files matched your search
+13
-2
@@ -129,7 +129,7 @@ func submit_run(record: Dictionary) -> bool:
|
||||
if not is_authenticated():
|
||||
return false
|
||||
var payload := record.duplicate(true)
|
||||
payload["client_version"] = "0.22"
|
||||
payload["client_version"] = "0.23"
|
||||
var result = await client.rpc_async(session, "submit_run", JSON.stringify(payload))
|
||||
var parsed := _parse_rpc_result(result)
|
||||
if parsed.is_empty() or not bool(parsed.get("accepted", false)):
|
||||
@@ -186,11 +186,22 @@ func load_leaderboard(map_index: int, difficulty_index: int, endless: bool, limi
|
||||
var result = await client.list_leaderboard_records_async(session, leaderboard_id, null, null, clampi(limit, 1, 100))
|
||||
if result == null or result.is_exception():
|
||||
return []
|
||||
var owner_ids := PackedStringArray()
|
||||
for record in result.records:
|
||||
if not record.owner_id.is_empty() and not owner_ids.has(record.owner_id):
|
||||
owner_ids.append(record.owner_id)
|
||||
var current_names := {}
|
||||
if not owner_ids.is_empty():
|
||||
var users_result = await client.get_users_async(session, owner_ids)
|
||||
if users_result != null and not users_result.is_exception():
|
||||
for user in users_result.users:
|
||||
if not user.display_name.is_empty():
|
||||
current_names[user.id] = user.display_name
|
||||
var rows: Array = []
|
||||
for record in result.records:
|
||||
rows.append({
|
||||
"rank": int(record.rank),
|
||||
"username": record.username,
|
||||
"username": str(current_names.get(record.owner_id, record.username)),
|
||||
"score": int(record.score),
|
||||
"wave": int(record.subscore),
|
||||
"owner_id": record.owner_id
|
||||
|
||||
Reference in new issue
Block a user