Commit eb690c9e authored by Nathan Lovato's avatar Nathan Lovato
Browse files

Add high score board UI

parent 13228a34
Pipeline #5060 passed with stage
in 4 minutes and 24 seconds
extends Control
onready var scores_column = $Column/ScoresColumn
const score_row = preload("res://ScoreBoard/ScoreRow.tscn")
func start():
for i in range(10):
var score_instance = score_row.instance()
scores_column.add_child(score_instance)
score_instance.setup(i)
score_instance.start()
func _ready() -> void:
start()
[gd_scene load_steps=4 format=2]
[ext_resource path="res://ScoreBoard/ScoreBoard.gd" type="Script" id=1]
[ext_resource path="res://assets/fonts/ScoreTitle.tres" type="DynamicFont" id=2]
[ext_resource path="res://ScoreBoard/ScoreRow.tscn" type="PackedScene" id=3]
[node name="ScoreBoard" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
[node name="Column" type="VBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 120.0
margin_top = 400.0
margin_right = -120.0
margin_bottom = -340.0
[node name="Title" type="Label" parent="Column"]
margin_right = 840.0
margin_bottom = 112.0
custom_fonts/font = ExtResource( 2 )
text = "High scores"
align = 1
uppercase = true
[node name="HSeparator" type="HSeparator" parent="Column"]
margin_top = 116.0
margin_right = 840.0
margin_bottom = 120.0
[node name="ScoresColumn" type="VBoxContainer" parent="Column"]
margin_top = 124.0
margin_right = 840.0
margin_bottom = 1180.0
size_flags_vertical = 3
[node name="ScoreRow" parent="Column/ScoresColumn" instance=ExtResource( 3 )]
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 0.0
margin_right = 840.0
margin_bottom = 88.0
extends Control
onready var rank_label := $Rank
onready var score_label := $Score
onready var initials_label := $Initials
onready var animation_player := $AnimationPlayer
const COLOR_TRANSPARENT = Color('00ffffff')
const COLOR_OPAQUE = Color('00ffffff')
func setup(index:int, score:int=1, initials:String="rms") -> void:
rank_label.set_rank(index)
score_label.text = "%03d" % score
initials_label.text = initials
func start() -> void:
"""Plays a fade-in animation"""
animation_player.play("fade_in")
func _ready() -> void:
modulate = COLOR_TRANSPARENT
[gd_scene load_steps=5 format=2]
[ext_resource path="res://ScoreBoard/ScoreRow.gd" type="Script" id=1]
[ext_resource path="res://assets/fonts/ScoreRow.tres" type="DynamicFont" id=2]
[sub_resource type="GDScript" id=1]
script/source = "extends Label
func set_rank(index:int) -> void:
var suffix := \"\"
match index:
0:
suffix = \"st\"
1:
suffix = \"nd\"
2:
suffix = \"rd\"
_:
suffix = \"th\"
text = \"%s%s\" % [index + 1, suffix]
"
[sub_resource type="Animation" id=2]
resource_name = "fade_in"
length = 0.4
tracks/0/type = "value"
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.4 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
}
[node name="ScoreRow" type="HBoxContainer"]
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
margin_top = -44.0
margin_bottom = 44.0
alignment = 1
script = ExtResource( 1 )
[node name="Rank" type="Label" parent="."]
margin_right = 357.0
margin_bottom = 88.0
size_flags_horizontal = 3
custom_fonts/font = ExtResource( 2 )
text = "1ST"
uppercase = true
script = SubResource( 1 )
[node name="Score" type="Label" parent="."]
margin_left = 361.0
margin_right = 718.0
margin_bottom = 88.0
size_flags_horizontal = 3
custom_fonts/font = ExtResource( 2 )
text = "001"
align = 1
uppercase = true
[node name="Initials" type="Label" parent="."]
margin_left = 722.0
margin_right = 1080.0
margin_bottom = 88.0
size_flags_horizontal = 3
custom_fonts/font = ExtResource( 2 )
text = "RMS"
align = 2
uppercase = true
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/fade_in = SubResource( 2 )
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://assets/fonts/Cabin-SemiBold.otf" type="DynamicFontData" id=1]
[resource]
size = 72
use_filter = true
font_data = ExtResource( 1 )
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://assets/fonts/Cabin-SemiBold.otf" type="DynamicFontData" id=1]
[resource]
size = 92
use_filter = true
font_data = ExtResource( 1 )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment