< 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:10
Uncovered lines:10
Coverable lines:20
Total lines:61
Line coverage:50% (10 of 20)
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%
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
 13        public virtual void Initialize()
 14        {
 3815            currentGeneralSettings = Settings.i.generalSettings;
 3816            currentQualitySetting = Settings.i.qualitySettings;
 17
 3818            Settings.i.OnGeneralSettingsChanged += OnGeneralSettingsChanged;
 3819            Settings.i.OnQualitySettingsChanged += OnQualitySettingsChanged;
 3820            Settings.i.OnResetAllSettings += OnResetSettingsControl;
 3821        }
 22
 23        public virtual void OnDestroy()
 24        {
 1725            Settings.i.OnGeneralSettingsChanged -= OnGeneralSettingsChanged;
 1726            Settings.i.OnQualitySettingsChanged -= OnQualitySettingsChanged;
 1727            Settings.i.OnResetAllSettings -= OnResetSettingsControl;
 1728        }
 29
 30        /// <summary>
 31        /// It should return the stored value of the control.
 32        /// </summary>
 33        /// <returns>It can be a bool (for toggle controls), a float (for slider controls) or an int (for spin-box contr
 034        public virtual object GetStoredValue() { return null; }
 35
 36        /// <summary>
 37        /// All the needed logic to applying the setting and storing the current value.
 38        /// </summary>
 39        /// <param name="newValue">Value of the new state. It can be a bool (for toggle controls), a float (for slider c
 040        public virtual void UpdateSetting(object newValue) { }
 41
 42        /// <summary>
 43        /// Applies the current control state into the Settings class.
 44        /// </summary>
 45        public virtual void ApplySettings()
 46        {
 047            Settings.i.ApplyGeneralSettings(currentGeneralSettings);
 048            Settings.i.ApplyQualitySettings(currentQualitySetting);
 049        }
 50
 051        private void OnGeneralSettingsChanged(SettingsData.GeneralSettings newGeneralSettings) { currentGeneralSettings 
 52
 053        private void OnQualitySettingsChanged(SettingsData.QualitySettings newQualitySettings) { currentQualitySetting =
 54
 55        private void OnResetSettingsControl()
 56        {
 057            currentGeneralSettings = Settings.i.generalSettings;
 058            currentQualitySetting = Settings.i.qualitySettings;
 059        }
 60    }
 61}