using UnityEngine;
using UnityEngine.UI;

public class MenuManager : MonoBehaviour
{
    public static MenuManager Instance => instance;
    private static MenuManager instance;

    [SerializeField]
    private GameObject m_menu;

    [SerializeField]
    private Button m_startButton;

    [SerializeField]
    private Button m_quitButton;

    [SerializeField]
    private GameObject m_hud;

    private void Awake()
    {
        instance = this;
    }

    private void Start()
    {
        m_startButton.onClick.AddListener(OnStartClick);
        m_quitButton.onClick.AddListener(() => Application.Quit());
    }

    public void OpenMenu(string btnText)
    {
        m_startButton.GetComponentInChildren<TMPro.TMP_Text>().text = btnText;
        m_menu.SetActive(true);
        m_hud.SetActive(false);
    }

    private void OnStartClick()
    {
        m_menu.SetActive(false);
        m_hud.SetActive(true);
        GameManager.Instance.StartOrContinue();
    }
}
