## HUD — heads-up display with back button, music toggle, and settings access.
class_name HUD extends CanvasLayer

const MUSIC_ON_SYMBOL: String = "♪"
const MUSIC_OFF_SYMBOL: String = "✕"

var _music_enabled: bool = true
@onready var _settings_menu: SettingsMenu = get_node_or_null("../SettingsMenu") as SettingsMenu


func _on_back_button_pressed() -> void:
	get_tree().quit()


func _on_music_toggle_pressed() -> void:
	_music_enabled = not _music_enabled
	var volume: float = AudioManager.DEFAULT_MUSIC_VOLUME if _music_enabled else 0.0
	AudioManager.set_music_volume(volume)
	var btn: Button = get_node_or_null("MusicToggle") as Button
	if btn != null:
		btn.text = MUSIC_ON_SYMBOL if _music_enabled else MUSIC_OFF_SYMBOL


func _on_settings_button_pressed() -> void:
	if _settings_menu != null:
		_settings_menu.show_menu()
