-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLeaderBoard.gd
43 lines (36 loc) · 1.14 KB
/
LeaderBoard.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
extends Control
var scores = ""
var OpenSeed
# warning-ignore:unused_signal
signal get_scores(number)
# Called when the node enters the scene tree for the first time.
func _ready():
OpenSeed = get_node("/root/OpenSeed")
pass
func update_board():
for score in scores.split("(b"):
var name = ""
var thescore = "N/A"
if score:
name = score.split("', '")[0].split("'")[1]
thescore = parse_json(score.split("', '")[1].split(")")[0])
var scores_display = $scoreC.duplicate()
var seperator = $HSeparator.duplicate()
scores_display.get_node("Name").text = name
scores_display.get_node("Score").text = thescore["score"]
$ScrollContainer/VBoxContainer.add_child(scores_display)
$ScrollContainer/VBoxContainer.add_child(seperator)
pass
func _on_leaderboard_get_scores(number):
clearBoard()
scores = OpenSeed.get_leaderboard(number)
update_board()
func _on_Close_Button_pressed():
self.hide()
clearBoard()
func clearBoard():
var items = $ScrollContainer/VBoxContainer.get_child_count()
while items >= 1:
var kid = $ScrollContainer/VBoxContainer.get_child(items)
$ScrollContainer/VBoxContainer.remove_child(kid)
items -=1