< 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:13
Uncovered lines:13
Coverable lines:26
Total lines:69
Line coverage:50% (13 of 26)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Initialize()0%110100%
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            currentGeneralSettings = Settings.i.generalSettings.Data;
 5917            currentQualitySetting = Settings.i.qualitySettings.Data;
 5918            currentAudioSettings = Settings.i.audioSettings.Data;
 19
 5920            Settings.i.generalSettings.OnChanged += OnGeneralSettingsChanged;
 5921            Settings.i.qualitySettings.OnChanged += OnQualitySettingsChanged;
 5922            Settings.i.audioSettings.OnChanged += OnAudioSettingsChanged;
 5923            Settings.i.OnResetAllSettings += OnResetSettingsControl;
 5924        }
 25
 26        public virtual void OnDestroy()
 27        {
 028            Settings.i.generalSettings.OnChanged -= OnGeneralSettingsChanged;
 029            Settings.i.qualitySettings.OnChanged -= OnQualitySettingsChanged;
 030            Settings.i.audioSettings.OnChanged -= OnAudioSettingsChanged;
 031            Settings.i.OnResetAllSettings -= OnResetSettingsControl;
 032        }
 33
 34        /// <summary>
 35        /// It should return the stored value of the control.
 36        /// </summary>
 37        /// <returns>It can be a bool (for toggle controls), a float (for slider controls) or an int (for spin-box contr
 038        public virtual object GetStoredValue() { return null; }
 39
 40        /// <summary>
 41        /// All the needed logic to applying the setting and storing the current value.
 42        /// </summary>
 43        /// <param name="newValue">Value of the new state. It can be a bool (for toggle controls), a float (for slider c
 044        public virtual void UpdateSetting(object newValue) { }
 45
 46        /// <summary>
 47        /// Applies the current control state into the Settings class.
 48        /// </summary>
 49        public virtual void ApplySettings()
 50        {
 1151            Settings.i.generalSettings.Apply(currentGeneralSettings);
 1152            Settings.i.qualitySettings.Apply(currentQualitySetting);
 1153            Settings.i.audioSettings.Apply(currentAudioSettings);
 1154        }
 55
 10056        private void OnGeneralSettingsChanged(GeneralSettings newGeneralSettings) { currentGeneralSettings = newGeneralS
 57
 058        private void OnQualitySettingsChanged(QualitySettings newQualitySettings) { currentQualitySetting = newQualitySe
 59
 060        private void OnAudioSettingsChanged(AudioSettings newAudioSettings) { currentAudioSettings = newAudioSettings; }
 61
 62        protected virtual void OnResetSettingsControl()
 63        {
 064            currentGeneralSettings = Settings.i.generalSettings.Data;
 065            currentQualitySetting = Settings.i.qualitySettings.Data;
 066            currentAudioSettings = Settings.i.audioSettings.Data;
 067        }
 68    }
 69}