xanarch-td/scripts/ui/RaceSelect.gd
2026-06-03 21:53:16 -04:00

42 lines
1.3 KiB
GDScript

## RaceSelect.gd
## Race selection screen shown at game start.
extends Control
signal race_selected(race: String)
const RACES = ["ghost", "fortress", "phantom", "ancient"]
@onready var btn_container: HBoxContainer = $VBox/ButtonRow
@onready var description_label: Label = $VBox/Description
@onready var confirm_btn: Button = $VBox/ConfirmButton
const DESCRIPTIONS = {
"ghost": "High damage, low HP. Glass cannon. Strong early and late game.",
"fortress": "Low damage, high HP. Buffs and debuffs. Strong early and mid game.",
"phantom": "Evasive and fast. Mixed melee/ranged. Strong mid and late game.",
"ancient": "Slow, massive AoE damage. Dominant late game.",
}
var _selected_race: String = ""
func _ready() -> void:
confirm_btn.disabled = true
confirm_btn.pressed.connect(_on_confirm)
for race in RACES:
var btn := Button.new()
btn.text = race.capitalize()
btn.toggle_mode = true
btn.pressed.connect(_on_race_btn_pressed.bind(btn, race))
btn_container.add_child(btn)
func _on_race_btn_pressed(btn: Button, race: String) -> void:
for child in btn_container.get_children():
child.button_pressed = false
btn.button_pressed = true
_selected_race = race
description_label.text = DESCRIPTIONS.get(race, "")
confirm_btn.disabled = false
func _on_confirm() -> void:
if _selected_race != "":
race_selected.emit(_selected_race)