class_name ItemSelector
extends Selector

@export var menu_items: Array[Label] = []
@export_group("Selector")
@export var cursor: String = "⏵"
@export var empty: String = " "


func _ready() -> void:
	item_count = menu_items.size()
	_navigate_item(0)


func _physics_process(_delta: float) -> void:
	if not handle_input():
		return

	if Input.is_action_just_pressed("a") or Input.is_action_just_pressed("start"):
		if select_sound:
			PulseSound0.load_and_play(select_sound)
		_on_item_selected(current_item)
		return

func _navigate_item(index: int) -> void:
	for i in range(menu_items.size()):
		var text: String = menu_items[i].text.right(-1)
		menu_items[i].text = (cursor if index == i else empty) + text
	_on_item_navigated(index)
