1
Fork 0
mirror of https://github.com/Steffo99/pineapple-surf.git synced 2024-11-21 23:34:21 +00:00

🎨 Improve code readability

This commit is contained in:
Ichicoro 2023-01-09 17:59:08 +01:00
parent 86cb3e407d
commit 0f0b7a00af
2 changed files with 15 additions and 0 deletions

View file

@ -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)

View file

@ -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