< Summary

Class:DCL.SettingsControls.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%110100%
GetStoredValue()0%2100%
UpdateSetting(...)0%2100%
ApplySettings()0%2100%
OnGeneralSettingsChanged(...)0%2100%
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.SettingsControls
 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 SettingsData.GeneralSettings currentGeneralSettings;
 11        protected SettingsData.QualitySettings currentQualitySetting;
 12        protected SettingsData.AudioSettings currentAudioSettings;
 13
 14        public virtual void Initialize()
 15        {
 4916            currentGeneralSettings = Settings.i.generalSettings;
 4917            currentQualitySetting = Settings.i.qualitySettings;
 4918            currentAudioSettings = Settings.i.audioSettings;
 19
 4920            Settings.i.OnGeneralSettingsChanged += OnGeneralSettingsChanged;
 4921            Settings.i.OnQualitySettingsChanged += OnQualitySettingsChanged;
 4922            Settings.i.OnAudioSettingsChanged += OnAudioSettingsChanged;
 4923            Settings.i.OnResetAllSettings += OnResetSettingsControl;
 4924        }
 25
 26        public virtual void OnDestroy()
 27        {
 2228            Settings.i.OnGeneralSettingsChanged -= OnGeneralSettingsChanged;
 2229            Settings.i.OnQualitySettingsChanged -= OnQualitySettingsChanged;
 2230            Settings.i.OnAudioSettingsChanged -= OnAudioSettingsChanged;
 2231            Settings.i.OnResetAllSettings -= OnResetSettingsControl;
 2232        }
 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        {
 051            Settings.i.ApplyGeneralSettings(currentGeneralSettings);
 052            Settings.i.ApplyQualitySettings(currentQualitySetting);
 053            Settings.i.ApplyAudioSettings(currentAudioSettings);
 054        }
 55
 056        private void OnGeneralSettingsChanged(SettingsData.GeneralSettings newGeneralSettings) { currentGeneralSettings 
 57
 058        private void OnQualitySettingsChanged(SettingsData.QualitySettings newQualitySettings) { currentQualitySetting =
 59
 060        private void OnAudioSettingsChanged(SettingsData.AudioSettings newAudioSettings) { currentAudioSettings = newAud
 61
 62        private void OnResetSettingsControl()
 63        {
 064            currentGeneralSettings = Settings.i.generalSettings;
 065            currentQualitySetting = Settings.i.qualitySettings;
 066            currentAudioSettings = Settings.i.audioSettings;
 067        }
 68    }
 69}