< Summary

Class:DCL.SettingsCommon.SettingsControllers.BaseControllers.SettingsControlController
Assembly:SettingsControllers
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Settings/SettingsControllers/BaseControllers/SettingsControlController.cs
Covered lines:14
Uncovered lines:14
Coverable lines:28
Total lines:72
Line coverage:50% (14 of 28)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Initialize()0%22090%
OnDestroy()0%2100%
GetStoredValue()0%2100%
UpdateSetting(...)0%2100%
ApplySettings()0%110100%
OnGeneralSettingsChanged(...)0%110100%
OnQualitySettingsChanged(...)0%2100%
OnAudioSettingsChanged(...)0%2100%
OnResetSettingsControl()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Settings/SettingsControllers/BaseControllers/SettingsControlController.cs

#LineLine coverage
 1using UnityEngine;
 2
 3namespace DCL.SettingsCommon.SettingsControllers.BaseControllers
 4{
 5    /// <summary>
 6    /// This controller is in charge of manage all the logic related to a SETTING CONTROL.
 7    /// </summary>
 8    public class SettingsControlController : ScriptableObject
 9    {
 10        protected GeneralSettings currentGeneralSettings;
 11        protected QualitySettings currentQualitySetting;
 12        protected AudioSettings currentAudioSettings;
 13
 14        public virtual void Initialize()
 15        {
 5916            if (Settings.i == null)
 017                Settings.CreateSharedInstance(new DefaultSettingsFactory());
 18
 5919            currentGeneralSettings = Settings.i.generalSettings.Data;
 5920            currentQualitySetting = Settings.i.qualitySettings.Data;
 5921            currentAudioSettings = Settings.i.audioSettings.Data;
 22
 5923            Settings.i.generalSettings.OnChanged += OnGeneralSettingsChanged;
 5924            Settings.i.qualitySettings.OnChanged += OnQualitySettingsChanged;
 5925            Settings.i.audioSettings.OnChanged += OnAudioSettingsChanged;
 5926            Settings.i.OnResetAllSettings += OnResetSettingsControl;
 5927        }
 28
 29        public virtual void OnDestroy()
 30        {
 031            Settings.i.generalSettings.OnChanged -= OnGeneralSettingsChanged;
 032            Settings.i.qualitySettings.OnChanged -= OnQualitySettingsChanged;
 033            Settings.i.audioSettings.OnChanged -= OnAudioSettingsChanged;
 034            Settings.i.OnResetAllSettings -= OnResetSettingsControl;
 035        }
 36
 37        /// <summary>
 38        /// It should return the stored value of the control.
 39        /// </summary>
 40        /// <returns>It can be a bool (for toggle controls), a float (for slider controls) or an int (for spin-box contr
 041        public virtual object GetStoredValue() { return null; }
 42
 43        /// <summary>
 44        /// All the needed logic to applying the setting and storing the current value.
 45        /// </summary>
 46        /// <param name="newValue">Value of the new state. It can be a bool (for toggle controls), a float (for slider c
 047        public virtual void UpdateSetting(object newValue) { }
 48
 49        /// <summary>
 50        /// Applies the current control state into the Settings class.
 51        /// </summary>
 52        public virtual void ApplySettings()
 53        {
 854            Settings.i.generalSettings.Apply(currentGeneralSettings);
 855            Settings.i.qualitySettings.Apply(currentQualitySetting);
 856            Settings.i.audioSettings.Apply(currentAudioSettings);
 857        }
 58
 9659        private void OnGeneralSettingsChanged(GeneralSettings newGeneralSettings) { currentGeneralSettings = newGeneralS
 60
 061        private void OnQualitySettingsChanged(QualitySettings newQualitySettings) { currentQualitySetting = newQualitySe
 62
 063        private void OnAudioSettingsChanged(AudioSettings newAudioSettings) { currentAudioSettings = newAudioSettings; }
 64
 65        protected virtual void OnResetSettingsControl()
 66        {
 067            currentGeneralSettings = Settings.i.generalSettings.Data;
 068            currentQualitySetting = Settings.i.qualitySettings.Data;
 069            currentAudioSettings = Settings.i.audioSettings.Data;
 070        }
 71    }
 72}