| | 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) |
| 0 | 25 | | return; |
| | 26 | |
|
| 1 | 27 | | QualitySettings preset = Settings.i.qualitySettingsPresets[value]; |
| 1 | 28 | | currentQualitySetting = preset; |
| 1 | 29 | | } |
| | 30 | |
|
| | 31 | | private void SetupQualityPresetLabels() |
| | 32 | | { |
| 2 | 33 | | List<string> presetNames = new List<string>(); |
| | 34 | | QualitySettings preset; |
| 20 | 35 | | for (int i = 0; i < Settings.i.qualitySettingsPresets.Length; i++) |
| | 36 | | { |
| 8 | 37 | | preset = Settings.i.qualitySettingsPresets[i]; |
| 8 | 38 | | presetNames.Add(preset.displayName); |
| | 39 | | } |
| | 40 | |
|
| 2 | 41 | | RaiseOnOverrideIndicatorLabel(presetNames.ToArray()); |
| 2 | 42 | | } |
| | 43 | |
|
| | 44 | | private void SetupQualityPresetLabelsWithCustom() |
| | 45 | | { |
| 0 | 46 | | List<string> presetNames = new List<string>(); |
| | 47 | | QualitySettings preset; |
| 0 | 48 | | for (int i = 0; i < Settings.i.qualitySettingsPresets.Length; i++) |
| | 49 | | { |
| 0 | 50 | | preset = Settings.i.qualitySettingsPresets[i]; |
| 0 | 51 | | presetNames.Add(preset.displayName); |
| | 52 | | } |
| 0 | 53 | | presetNames.Add(TEXT_QUALITY_CUSTOM); |
| 0 | 54 | | RaiseOnOverrideIndicatorLabel(presetNames.ToArray()); |
| 0 | 55 | | } |
| | 56 | |
|
| | 57 | | private int GetCurrentStoredValue() |
| | 58 | | { |
| | 59 | | QualitySettings preset; |
| 4 | 60 | | for (int i = 0; i < Settings.i.qualitySettingsPresets.Length; i++) |
| | 61 | | { |
| 2 | 62 | | preset = Settings.i.qualitySettingsPresets[i]; |
| 2 | 63 | | if (preset.Equals(currentQualitySetting)) |
| | 64 | | { |
| 1 | 65 | | SetupQualityPresetLabels(); |
| 1 | 66 | | RaiseOnCurrentLabelChange(preset.displayName); |
| 1 | 67 | | return i; |
| | 68 | | } |
| | 69 | | } |
| | 70 | |
|
| 0 | 71 | | SetupQualityPresetLabelsWithCustom(); |
| 0 | 72 | | RaiseOnCurrentLabelChange(TEXT_QUALITY_CUSTOM); |
| 0 | 73 | | return Settings.i.qualitySettingsPresets.Length; |
| | 74 | | } |
| | 75 | | } |
| | 76 | | } |