| | 1 | | using DCL.SettingsCommon.SettingsControllers.BaseControllers; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | namespace DCL.SettingsCommon.SettingsControllers.SpecificControllers |
| | 5 | | { |
| | 6 | | [CreateAssetMenu(menuName = "Settings/Controllers/Controls/Night Mode", fileName = "NightModeControlController")] |
| | 7 | | public class NightModeControlController : ToggleSettingsControlController |
| | 8 | | { |
| | 9 | | public override void Initialize() |
| | 10 | | { |
| 2 | 11 | | base.Initialize(); |
| | 12 | |
|
| 2 | 13 | | RenderProfileManifest.i.OnChangeProfile += OnChangeProfile; |
| 2 | 14 | | OnChangeProfile(RenderProfileManifest.i.currentProfile); |
| 2 | 15 | | } |
| | 16 | |
|
| 2 | 17 | | public override object GetStoredValue() { return currentGeneralSettings.nightMode; } |
| | 18 | |
|
| | 19 | | public override void UpdateSetting(object newValue) |
| | 20 | | { |
| 2 | 21 | | currentGeneralSettings.nightMode = (bool)newValue; |
| 2 | 22 | | RenderProfileManifest.i.currentProfile = currentGeneralSettings.nightMode ? RenderProfileManifest.i.nightPro |
| 2 | 23 | | RenderProfileManifest.i.currentProfile.Apply(); |
| 2 | 24 | | } |
| | 25 | |
|
| | 26 | | public override void OnDestroy() |
| | 27 | | { |
| 0 | 28 | | base.OnDestroy(); |
| | 29 | |
|
| 0 | 30 | | RenderProfileManifest.i.OnChangeProfile -= OnChangeProfile; |
| 0 | 31 | | } |
| | 32 | |
|
| | 33 | | private void OnChangeProfile(RenderProfileWorld profile) |
| | 34 | | { |
| 46 | 35 | | currentGeneralSettings.nightMode = profile == RenderProfileManifest.i.nightProfile; |
| 46 | 36 | | ApplySettings(); |
| 46 | 37 | | } |
| | 38 | | } |
| | 39 | | } |