using Godot;
using System;

public partial class PauseMenu : Control
{
	private static PauseMenu Instance;
	private bool previousPaused;
	private bool currently_paused = false;
	private AudioStream pauseSound = ResourceLoader.Load<AudioStream>("uid://ckja8ym50y0d4");
    public override void _Ready()
	{
		Instance = this;
	}

	public void Continue()
	{
		GetParent<Control>().Visible = false;
		GetTree().Paused = previousPaused;
		currently_paused = false;
	}
	public void Restart()
	{
		GetTree().Paused = false;
		GetTree().ReloadCurrentScene();
		currently_paused = false;
	}
	public void Exit()
	{
		GetTree().ChangeSceneToFile("uid://bfstrli64u23y");
		currently_paused = false;
	}
	public static void Pause()
	{
		if (Instance.currently_paused)
		{
			return;
		}
		Instance.GetParent<Control>().Visible = true;
		Instance.previousPaused = Instance.GetTree().Paused;
		Instance.GetTree().Paused = true;
		Instance.currently_paused = true;
		AudioSequencer.Play("pause",Instance.pauseSound);
	}
}
