using UnityEngine;
using UnityEngine.UI;

using ftt.Core.Managing;

namespace UI
{
    public class OptionsPauseMenu : MonoBehaviour
    {
        [SerializeField] Slider masterVolumeSlider;
        [SerializeField] Slider mouseSensivitySlider;
        [SerializeField] Button backButton;

        // Start is called before the first frame update
        void Start()
        {
            EntrySetup();
        }

        void EntrySetup()
        {
            masterVolumeSlider.onValueChanged.AddListener(delegate { MasterVolume(); });
            mouseSensivitySlider.onValueChanged.AddListener(delegate { MouseSensivity(); });

            backButton.onClick.AddListener(Back);
        }

        void MasterVolume()
        {
            GameManager.GetManager.SoundsHandler.SetVolume(masterVolumeSlider.value);
        }

        void MouseSensivity()
        {
            UI.UIManager.S.SetSensitivity((int)mouseSensivitySlider.value);
        }

        void Back()
        {
            if (GameManager.GetManager.CurrentState == GameStates.PLAYING)
            {
                UIManager.S.EnablePanel("PauseMenu");
            }
            else
            {
                UIManager.S.EnablePanel("StartMenu");
            }
        }
    }
}
