using Unity.VectorGraphics;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class MainMenuManager : MonoBehaviour
{

    [Header("UI")]
    [SerializeField] private Button startButton;
    [SerializeField] private Button quitButton;

    private string sceneName = ("Tuto");

    private void Awake()
    {
        // Subscribe UI buttons
        if (startButton != null)
            startButton.onClick.AddListener(GameStart);

        if (quitButton != null)
            quitButton.onClick.AddListener(QuitGame);
    }

    private void OnDestroy()
    {
        // Unsubscribe UI buttons
        if (startButton != null)
            startButton.onClick.RemoveListener(GameStart);

        if (quitButton != null)
            quitButton.onClick.RemoveListener(QuitGame);
    }

    public void GameStart()
    {
        SceneManager.LoadScene(sceneName);
    }

    public void QuitGame()
    {
        Time.timeScale = 1f;

#if UNITY_EDITOR
        Debug.Log("[Pause] Quit Game");
        UnityEditor.EditorApplication.isPlaying = false;
#else
        Application.Quit();
#endif
    }
}
