| | 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 | | 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 | |
|
| 0 | 17 | | public override object GetStoredValue() { return currentDisplaySettings.fpsCapIndex; } |
| | 18 | |
|
| | 19 | | private void SetupLabels() |
| | 20 | | { |
| 0 | 21 | | var length = allFpsValues.Length; |
| 0 | 22 | | var fpsLabels = new string[length]; |
| 0 | 23 | | for (var i = 0; i < length; i++) |
| | 24 | | { |
| 0 | 25 | | fpsLabels[i] = allFpsValues[i] > 0 ? allFpsValues[i].ToString() + " FPS" : "Max"; |
| | 26 | | } |
| | 27 | |
|
| 0 | 28 | | RaiseOnOverrideIndicatorLabel(fpsLabels); |
| 0 | 29 | | } |
| | 30 | |
|
| | 31 | | public override void UpdateSetting(object newValue) |
| | 32 | | { |
| 0 | 33 | | var fpsValue = (int)allFpsValues[(int)newValue]; |
| 0 | 34 | | currentDisplaySettings.fpsCapIndex = (int)newValue; |
| 0 | 35 | | ToggleFPSCap(fpsValue); |
| 0 | 36 | | } |
| | 37 | |
|
| | 38 | | public static void ToggleFPSCap(int fpsValue) |
| | 39 | | { |
| 0 | 40 | | Application.targetFrameRate = fpsValue; |
| 0 | 41 | | } |
| | 42 | | } |
| | 43 | | } |