using UnityEngine;

namespace NBF.Setting
{
    /// <summary>
    /// 画质设置
    /// </summary>
    [Sort(3)]
    public class QualityLevelSetting : MultiOption<int>
    {
        private int _defaultQualityLevel;
        public override string Name => "QualityLevel";
        public override string Group => SettingsDef.Group.Graphic;
        public override string Tab => SettingsDef.Tab.Graphic;
        protected override int DefaultValue => _defaultQualityLevel;

        protected override void OnInitialize()
        {
            var names = QualitySettings.names;

            for (int i = 0; i < names.Length; i++)
            {
                AddOption(names[i], i);
            }

            _defaultQualityLevel = QualitySettings.GetQualityLevel();
        }

        protected override void OnApply()
        {
            QualitySettings.SetQualityLevel(GetSelectedOption());
        }
    }
}