| | 1 | | using System; |
| | 2 | | using MainScripts.DCL.Controllers.SettingsDesktop; |
| | 3 | | using MainScripts.DCL.Controllers.SettingsDesktop.SettingsControllers; |
| | 4 | | using MainScripts.DCL.ScriptableObjectsDesktop; |
| | 5 | | using UnityEngine; |
| | 6 | |
|
| | 7 | | namespace MainScripts.DCL.Controllers.HUD.SettingsPanelHUDDesktop.Scripts |
| | 8 | | { |
| | 9 | | [CreateAssetMenu(menuName = "Settings/Controllers/Controls/Window Mode", |
| | 10 | | fileName = "WindowModeControlController")] |
| | 11 | | public class WindowModeControlController : SpinBoxSettingsControlControllerDesktop |
| | 12 | | { |
| | 13 | | public override object GetStoredValue() |
| | 14 | | { |
| 0 | 15 | | return (int)currentDisplaySettings.windowMode; |
| | 16 | | } |
| | 17 | |
|
| | 18 | | public override void UpdateSetting(object newValue) |
| | 19 | | { |
| 0 | 20 | | currentDisplaySettings.windowMode = (WindowMode)(int)newValue; |
| | 21 | |
|
| 0 | 22 | | switch (currentDisplaySettings.windowMode) |
| | 23 | | { |
| | 24 | | case WindowMode.Windowed: |
| | 25 | | case WindowMode.FullScreen: |
| 0 | 26 | | UpdateResolution(); |
| 0 | 27 | | break; |
| | 28 | | case WindowMode.Borderless: |
| 0 | 29 | | SetupBorderless(); |
| 0 | 30 | | break; |
| | 31 | | default: |
| 0 | 32 | | throw new ArgumentOutOfRangeException(); |
| | 33 | | } |
| | 34 | |
|
| 0 | 35 | | CommonScriptableObjectsDesktop.disableVSync.Set(currentDisplaySettings.windowMode == WindowMode.Windowed); |
| 0 | 36 | | CommonScriptableObjectsDesktop.disableScreenResolution.Set(currentDisplaySettings.windowMode == WindowMode.B |
| 0 | 37 | | } |
| | 38 | |
|
| | 39 | | private void SetupBorderless() |
| | 40 | | { |
| 0 | 41 | | ApplySettings(); |
| 0 | 42 | | UpdateResolution(); |
| 0 | 43 | | } |
| | 44 | |
|
| | 45 | | private void UpdateResolution() |
| | 46 | | { |
| 0 | 47 | | ScreenResolutionUtils.Apply(currentDisplaySettings); |
| 0 | 48 | | } |
| | 49 | | } |
| | 50 | | } |