extends CanvasLayer

const DEFAULT_TEXT: String = "{game_name} - {state} - V - {version}"
const UNDEFINED_TEXT: String = "Undefined"

@export_enum("Pre-Alpha", "Early-Alpha", "Alpha", "Beta", "Early-Access", "Release") var state: String = "Pre-Alpha"
@export_multiline var text_override: String = DEFAULT_TEXT: set = set_text

@onready var version_label: Label = $MarginContainer/VersionLabel


func _ready() -> void:
	set_text(text_override)


func set_text(new_text: String) -> void:
	new_text = new_text.replace("{game_name}", ProjectSettings.get_setting("application/config/name", UNDEFINED_TEXT))
	new_text = new_text.replace("{version}", ProjectSettings.get_setting("application/config/version", UNDEFINED_TEXT))
	new_text = new_text.replace("{state}", str(state))
	
	text_override = new_text
	
	_update_hud()


func _update_hud() -> void:
	if not self.is_node_ready():
		await self.ready
	
	version_label.set_text(text_override)
