extends Level
class_name MainMenu

@onready var level_select = get_node("%MenuButton")
@onready var high_scores = get_node("%HighScores")
@onready var exit_button = get_node("%ExitGame")

func _ready():
	level_select.get_popup().id_pressed.connect(_on_item_menu_pressed)
	high_scores.connect("pressed", Callable(self, "on_high_scores_pressed"))
	exit_button.connect("pressed", Callable(self, "on_exit_pressed"))
	update_game_state()


func _on_item_menu_pressed(id):
	## Load the appropriate level based on the selection that has been made 
	Log.pr(id)

	match id:
		1:
			# Load level 1
			SceneMgr.load_scene("LEVEL1")
		2:
			# Load level 2
			SceneMgr.load_scene("LEVEL2")
		3:
			# Load level 3
			SceneMgr.load_scene("LEVEL3")
		4:
			# Load level 4
			SceneMgr.load_scene("LEVEL4")
		5:
			# Load level 5
			SceneMgr.load_scene("LEVEL5")
		6:
			# Load level 6
			SceneMgr.load_scene("LEVEL6")

func on_high_scores_pressed():
	## Load the high scores screen
	Log.pr("High scores button pressed")
	SceneMgr.load_scene("HIGHSCORES")
	pass

func on_exit_pressed():
	# Quit the game 
	get_tree().quit()
