@tool
extends HBoxContainer

@export var distance : int = 20000 : set = set_distance
@export var destination : String = "BOREA_BASE" : set = set_destination
@export var stop_name : String = "" : set = set_stop_name
@export var stop_title : String = "NEXT_STOP" : set = set_stop_title

func _ready():
    set_distance()
    set_stop_name()
    set_stop_title()

func set_distance(v : int = distance):
    distance = v
    if is_node_ready():
        var str_distance = str(distance)
        var nb_len = len(str_distance)
        var shift = 0
        for i in range(nb_len):
            if i%3 == 0:
                shift += 1
                str_distance = str_distance.insert(len(str_distance) - i - 2 - shift," ")
        %DistanceLabel.text = str_distance

func set_stop_name(v : String = stop_name):
    stop_name = v
    if is_node_ready():
        %NextStopLabel.text = tr(str(v))

func set_stop_title(v : String = stop_title):
    stop_title = v
    if is_node_ready():
        %NextStopTitleLabel.text = tr(str(v))
        %VSeparator.visible = v != ""
        %DetailsContainer.visible = v != ""

func set_destination(v : String = destination):
    destination = v
    if is_node_ready():
        %DestinationLabel.text = tr(str(v))
