47 lines
1.2 KiB
GDScript
47 lines
1.2 KiB
GDScript
tool
|
|
extends HBoxContainer
|
|
|
|
const DIFFICULTY_ICONS = [
|
|
preload("res://graphics/hud/scores/sweet.png"),
|
|
preload("res://graphics/hud/scores/salty.png"),
|
|
preload("res://graphics/hud/scores/spicy.png"),
|
|
preload("res://graphics/hud/scores/pungent.png"),
|
|
]
|
|
|
|
export var place: int = 0 setget _set_place
|
|
export var player: String = "Username" setget _set_player
|
|
export var score: int = 0 setget _set_score
|
|
export var time: float = 0.0 setget _set_time
|
|
export(int, "Sweet", "Salty", "Spicy", "Pungent") var difficulty: int = 0 setget _set_difficulty
|
|
|
|
func _ready() -> void:
|
|
_set_place(place)
|
|
_set_player(player)
|
|
_set_score(score)
|
|
_set_time(time)
|
|
_set_difficulty(difficulty)
|
|
|
|
func _set_place(value: int) -> void:
|
|
place = value
|
|
if is_inside_tree():
|
|
$Place.text = "%d" % place
|
|
|
|
func _set_player(value: String) -> void:
|
|
player = value.substr(0, 10)
|
|
if is_inside_tree():
|
|
$Player.text = player
|
|
|
|
func _set_score(value: int) -> void:
|
|
score = value
|
|
if is_inside_tree():
|
|
$Score.text = "%05d" % score
|
|
|
|
func _set_time(value: float) -> void:
|
|
time = value
|
|
if is_inside_tree():
|
|
$Time.text = Game.format_time(time)
|
|
|
|
func _set_difficulty(value: int) -> void:
|
|
difficulty = value
|
|
if is_inside_tree():
|
|
$Difficulty.texture = DIFFICULTY_ICONS[difficulty]
|