diff --git a/menu/Menu.gd b/menu/Menu.gd index a68d887..bd26836 100644 --- a/menu/Menu.gd +++ b/menu/Menu.gd @@ -5,6 +5,8 @@ signal play_pressed() var scores_downloaded := false var scores := [] as Array[Array] +var score_scene := preload("res://menu/score.tscn") + var is_uploading := false var should_open_scores_after_upload := false @@ -45,9 +47,21 @@ func _fetch_scores(open_after: bool = false): httpreq.connect("request_completed", func(result, response_code, headers, body): var json = JSON.parse_string(body.get_string_from_utf8()) self.scores = (json as Array).map(func(element): return [element.name, element.score]) + + for child in %ScoresVBox.get_children(): + child.queue_free() + + for score in self.scores: + var score_sc = score_scene.instantiate() + score_sc.get_node("HBoxContainer/Name").text = score[0] + score_sc.get_node("HBoxContainer/Score").text = "%d" % score[1] + %ScoresVBox.add_child(score_sc) + self.scores_downloaded = true %ScoresButton.disabled = false print(self.scores) + if open_after: + open_scores() httpreq.queue_free() ) httpreq.request(url) diff --git a/menu/Menu.tscn b/menu/Menu.tscn index a0a7f45..731cdc0 100644 --- a/menu/Menu.tscn +++ b/menu/Menu.tscn @@ -111,6 +111,7 @@ text = "Ludum Dare 52 - Harvest" horizontal_alignment = 1 [node name="ScoreboardContainer" type="Control" parent="."] +visible = false layout_mode = 1 anchors_preset = 15 anchor_right = 1.0