| | 1 | | using UnityEngine; |
| | 2 | |
|
| | 3 | | namespace MainScripts.DCL.Controllers.SettingsDesktop.SettingsControllers |
| | 4 | | { |
| | 5 | | [CreateAssetMenu(menuName = "Settings/Controllers/Controls/FPS Limit", fileName = "FPSLimitControlController")] |
| | 6 | | public class FPSLimitControlController : SpinBoxSettingsControlControllerDesktop |
| | 7 | | { |
| | 8 | | private int[] allFpsValues; |
| | 9 | |
|
| | 10 | | public override void Initialize() |
| | 11 | | { |
| 0 | 12 | | allFpsValues = (int[])System.Enum.GetValues(typeof(FpsCapMode)); |
| 0 | 13 | | base.Initialize(); |
| 0 | 14 | | SetupLabels(); |
| 0 | 15 | | } |
| | 16 | |
|
| | 17 | | public override object GetStoredValue() => |
| 0 | 18 | | currentDisplaySettings.fpsCapIndex; |
| | 19 | |
|
| | 20 | | private void SetupLabels() |
| | 21 | | { |
| 0 | 22 | | int length = allFpsValues.Length; |
| 0 | 23 | | var fpsLabels = new string[length]; |
| | 24 | |
|
| 0 | 25 | | for (var i = 0; i < length; i++) |
| 0 | 26 | | fpsLabels[i] = allFpsValues[i] > 0 ? allFpsValues[i] + " FPS" : "Max"; |
| | 27 | |
|
| 0 | 28 | | RaiseOnOverrideIndicatorLabel(fpsLabels); |
| 0 | 29 | | } |
| | 30 | |
|
| | 31 | | public override void UpdateSetting(object newValue) |
| | 32 | | { |
| 0 | 33 | | currentDisplaySettings.fpsCapIndex = (int)newValue; |
| 0 | 34 | | Application.targetFrameRate = allFpsValues[(int)newValue]; |
| | 35 | |
|
| 0 | 36 | | ApplySettings(); |
| 0 | 37 | | } |
| | 38 | | } |
| | 39 | | } |