| | 1 | | using System.Collections.Generic; |
| | 2 | | using DCL.SettingsCommon.SettingsControllers.BaseControllers; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace DCL.SettingsCommon.SettingsControllers.SpecificControllers |
| | 6 | | { |
| | 7 | | [CreateAssetMenu(menuName = "Settings/Controllers/Controls/Quality Preset", fileName = "QualityPresetControlControll |
| | 8 | | public class QualityPresetControlController : SpinBoxSettingsControlController |
| | 9 | | { |
| | 10 | | public const string TEXT_QUALITY_CUSTOM = "Custom"; |
| | 11 | |
|
| | 12 | | public override void Initialize() |
| | 13 | | { |
| 1 | 14 | | base.Initialize(); |
| | 15 | |
|
| 1 | 16 | | SetupQualityPresetLabels(); |
| 1 | 17 | | } |
| | 18 | |
|
| 1 | 19 | | public override object GetStoredValue() { return GetCurrentStoredValue(); } |
| | 20 | |
|
| | 21 | | public override void UpdateSetting(object newValue) |
| | 22 | | { |
| 1 | 23 | | int value = (int)newValue; |
| 1 | 24 | | if (value != Settings.i.qualitySettingsPresets.Length) |
| 1 | 25 | | currentQualitySetting = Settings.i.qualitySettingsPresets[value]; |
| 1 | 26 | | } |
| | 27 | |
|
| | 28 | | private void SetupQualityPresetLabels(params string[] customs) |
| | 29 | | { |
| 2 | 30 | | List<string> presetNames = new List<string>(); |
| | 31 | |
|
| 20 | 32 | | for (int i = 0; i < Settings.i.qualitySettingsPresets.Length; i++) |
| 8 | 33 | | presetNames.Add(Settings.i.qualitySettingsPresets[i].displayName); |
| | 34 | |
|
| 2 | 35 | | presetNames.AddRange(customs); |
| | 36 | |
|
| 2 | 37 | | RaiseOnOverrideIndicatorLabel(presetNames.ToArray()); |
| 2 | 38 | | } |
| | 39 | |
|
| | 40 | | private int GetCurrentStoredValue() |
| | 41 | | { |
| 4 | 42 | | for (int i = 0; i < Settings.i.qualitySettingsPresets.Length; i++) |
| | 43 | | { |
| 2 | 44 | | QualitySettings preset = Settings.i.qualitySettingsPresets[i]; |
| | 45 | |
|
| 2 | 46 | | if (preset.Equals(currentQualitySetting)) |
| | 47 | | { |
| 1 | 48 | | SetupQualityPresetLabels(); |
| 1 | 49 | | RaiseOnCurrentLabelChange(preset.displayName); |
| 1 | 50 | | return i; |
| | 51 | | } |
| | 52 | | } |
| | 53 | |
|
| 0 | 54 | | SetupQualityPresetLabels(TEXT_QUALITY_CUSTOM); |
| 0 | 55 | | RaiseOnCurrentLabelChange(TEXT_QUALITY_CUSTOM); |
| 0 | 56 | | return Settings.i.qualitySettingsPresets.Length; |
| | 57 | | } |
| | 58 | | } |
| | 59 | | } |