< Summary

Class:DCL.SettingsControls.SkyboxTimeControlController
Assembly:SettingsControllers
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Settings/SettingsControllers/SpecificControllers/SkyboxTimeControlController.cs
Covered lines:14
Uncovered lines:4
Coverable lines:18
Total lines:48
Line coverage:77.7% (14 of 18)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SkyboxTimeControlController()0%110100%
Initialize()0%110100%
OnSkyboxModeChanged(...)0%6200%
GetStoredValue()0%220100%
UpdateSetting(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Settings/SettingsControllers/SpecificControllers/SkyboxTimeControlController.cs

#LineLine coverage
 1using DCL.SettingsCommon.SettingsControllers.BaseControllers;
 2using UnityEngine;
 3
 4namespace DCL.SettingsControls
 5{
 6    [CreateAssetMenu(menuName = "Settings/Controllers/Controls/Skybox Time", fileName = "SkyboxTime")]
 7    public class SkyboxTimeControlController : SliderSettingsControlController
 8    {
 29        private readonly DataStore_SkyboxConfig skyboxConfig = DataStore.i.skyboxConfig;
 10
 11        public override void Initialize()
 12        {
 113            base.Initialize();
 114            UpdateSetting(currentGeneralSettings.skyboxTime);
 15
 116            skyboxConfig.mode.OnChange += OnSkyboxModeChanged;
 117        }
 18
 19        private void OnSkyboxModeChanged(SkyboxMode current, SkyboxMode previous)
 20        {
 021            if (current == previous) return;
 22
 023            RaiseSliderValueChanged((float)GetStoredValue());
 024            UpdateSetting(GetStoredValue());
 025        }
 26
 27        public override object GetStoredValue() =>
 128            skyboxConfig.mode.Equals(SkyboxMode.Dynamic)
 29                ? (object)currentGeneralSettings.skyboxTime
 30                : skyboxConfig.fixedTime.Get();
 31
 32        public override void UpdateSetting(object newValue)
 33        {
 234            var valueAsFloat = (float)newValue;
 35
 236            valueAsFloat = Mathf.Clamp(valueAsFloat, 0, 23.998f);
 37
 238            currentGeneralSettings.skyboxTime = valueAsFloat;
 39
 240            var hourSection = (int)valueAsFloat;
 241            var minuteSection = (int)((valueAsFloat - hourSection) * 60);
 42
 243            RaiseOnIndicatorLabelChange($"{hourSection:00}:{minuteSection:00}");
 44
 245            skyboxConfig.fixedTime.Set(valueAsFloat);
 246        }
 47    }
 48}