< 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:15
Uncovered lines:11
Coverable lines:26
Total lines:69
Line coverage:57.6% (15 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%110100%
OnAudioSettingsChanged(...)0%110100%
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        {
 5016            currentGeneralSettings = Settings.i.generalSettings.Data;
 5017            currentQualitySetting = Settings.i.qualitySettings.Data;
 5018            currentAudioSettings = Settings.i.audioSettings.Data;
 19
 5020            Settings.i.generalSettings.OnChanged += OnGeneralSettingsChanged;
 5021            Settings.i.qualitySettings.OnChanged += OnQualitySettingsChanged;
 5022            Settings.i.audioSettings.OnChanged += OnAudioSettingsChanged;
 5023            Settings.i.OnResetAllSettings += OnResetSettingsControl;
 5024        }
 25
 26        public virtual void OnDestroy()
 27        {
 2228            Settings.i.generalSettings.OnChanged -= OnGeneralSettingsChanged;
 2229            Settings.i.qualitySettings.OnChanged -= OnQualitySettingsChanged;
 2230            Settings.i.audioSettings.OnChanged -= 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.generalSettings.Apply(currentGeneralSettings);
 052            Settings.i.qualitySettings.Apply(currentQualitySetting);
 053            Settings.i.audioSettings.Apply(currentAudioSettings);
 054        }
 55
 056        private void OnGeneralSettingsChanged(GeneralSettings newGeneralSettings) { currentGeneralSettings = newGeneralS
 57
 5858        private void OnQualitySettingsChanged(QualitySettings newQualitySettings) { currentQualitySetting = newQualitySe
 59
 11260        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}