extends CanvasLayer
@onready var option_popup = $OptionPopup
@onready var back_button = $TextureRect/back
@onready var save_button = $TextureRect/save

func _ready():
	$TextureRect/start.connect("pressed", Callable(self, "_on_start_pressed"))
	$TextureRect/exit.connect("pressed", Callable(self, "_on_exit_pressed"))
	$TextureRect/option.connect("pressed", Callable(self, "_on_opcje_pressed"))
	$TextureRect/back.connect("pressed", Callable(self, "_on_back_pressed"))
	Engine.time_scale = 1.0
	
	
	if GameData.game_lunched == true:
		back_button.visible = true
		save_button.visible = true
	else :
		back_button.visible = false
		save_button.visible = false



func _on_opcje_pressed():
	option_popup.popup_centered()


func _on_start_pressed():
	
	get_tree().change_scene_to_file("res://scenes/galaxy.tscn")
	

func _on_exit_pressed():
	get_tree().quit()
	
func _on_back_pressed():
	var cam = get_parent().get_node_or_null("Camera2D")
	if cam:
		cam.enabled = true
		cam.make_current()  # ustawia kamerę jako aktywną
		

	get_tree().paused = false
	queue_free()  # usuwa menu z ekranu

	
