@tool
extends Interactable3D
class_name DashboardMainScreen

enum State {READY_TO_TAKE_OFF,READY_TO_LAND,WAITING_CHOICE,LANDED}

const TAKE_OFF_ICON = preload("res://common/icons/chevrons-up.svg")
const LAND_ICON = preload("res://common/icons/arrow-narrow-down.svg")
const RUN_POINT_ICON = preload("res://common/icons/map-pin.svg")
const WAITING_ICON = preload("res://common/icons/help-hexagon.svg")

func _ready():
    set_state()

@export var icon : TextureRect 
@export var label : Label 
@export var state : State = State.LANDED : set = set_state

@export var run_point : RunPoint

func set_state(s := state):
    state = s
    if is_node_ready():
        interactable = false
        inspectable = false
        match state:
            State.READY_TO_TAKE_OFF:
                icon.texture = TAKE_OFF_ICON
                label.text = tr("TAKE_OFF")
                interactable = true
            State.READY_TO_LAND:
                icon.texture = LAND_ICON
                label.text = tr("LAND_SHIP_IN_%S") % run_point.region_parameter.get_region_name()
                interactable = true
                inspectable = true
            State.WAITING_CHOICE:
                icon.texture = WAITING_ICON
                label.text = "CHOOSE_A_REGION"
            State.LANDED:
                icon.texture = RUN_POINT_ICON
                label.text = "" if not run_point else run_point.region_parameter.get_region_name()
                inspectable = true

func card_info() -> CardInfo:
    if run_point and state == State.LANDED:
        var info = run_point.card_info()
        info.subtitle = tr("LOCATION")
        return info
    return null
