extends Control

var is_paused = false


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	if Input.is_action_just_pressed("Pause"):
		is_paused = !is_paused
		get_tree().paused = is_paused
		visible = is_paused
		Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE if is_paused else Input.MOUSE_MODE_CAPTURED)

func unpause_game():
	is_paused = false
	get_tree().paused = false
	visible = false
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
	pass

func _on_restart_stage_pressed() -> void:
	if (WholePlayer.getThisStage):
		unpause_game()
		get_tree().change_scene_to_file(WholePlayer.getThisStage)


func _on_next_stage_pressed() -> void:
	if (WholePlayer.getNextStage):
		unpause_game()
		get_tree().change_scene_to_file(WholePlayer.getNextStage)


func _on_previous_stage_pressed() -> void:
	if (WholePlayer.getPrevStage):
		unpause_game()
		get_tree().change_scene_to_file(WholePlayer.getPrevStage)


func _on_main_menu_pressed() -> void:
	unpause_game()
	get_tree().change_scene_to_file("res://Scenes/Stages/game_start.tscn")
