< Summary

Class:DCL.SettingsCommon.DefaultSettingsFactory
Assembly:Settings
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Settings/DefaultSettingsFactory.cs
Covered lines:10
Uncovered lines:4
Coverable lines:14
Total lines:102
Line coverage:71.4% (10 of 14)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
DefaultSettingsFactory()0%110100%
WithDefaultGeneralSettings(...)0%2100%
WithGraphicsQualitySettingsPresetPath(...)0%2100%
Build()0%110100%
CreateAudioSettingsRepository()0%110100%
CreateGeneralSettingsRepository()0%110100%
CreateGraphicsQualityRepository(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Settings/DefaultSettingsFactory.cs

#LineLine coverage
 1using UnityEngine;
 2using UnityEngine.Audio;
 3
 4namespace DCL.SettingsCommon
 5{
 6    public class DefaultSettingsFactory : ISettingsFactory
 7    {
 8        const string QUALITY_SETTINGS_KEY = "Settings.Quality";
 9        const string GENERAL_SETTINGS_KEY = "Settings.General";
 10        const string AUDIO_SETTINGS_KEY = "Settings.Audio";
 11
 64012        private string graphicsQualitySettingsPresetPath = "ScriptableObjects/QualitySettingsData";
 64013        private string audioMixerPath = "AudioMixer";
 14
 64015        private GeneralSettings defaultGeneralSettings = new GeneralSettings
 16        {
 17            mouseSensitivity = 0.6f,
 18            scenesLoadRadius = 4,
 19            avatarsLODDistance = 16,
 20            maxNonLODAvatars = DataStore_AvatarsLOD.DEFAULT_MAX_AVATAR,
 21            voiceChatVolume = 1,
 22            voiceChatAllow = GeneralSettings.VoiceChatAllow.ALL_USERS,
 23            namesOpacity = 0.5f,
 24            profanityChatFiltering = true,
 25            nightMode = false,
 26            hideUI = false,
 27            showAvatarNames = true,
 28            dynamicProceduralSkybox = true,
 29            invertYAxis = false,
 30            skyboxTime = 0.0f,
 31            firstPersonCameraFOV = 60
 32        };
 33
 64034        private AudioSettings defaultAudioSettings = new AudioSettings
 35        {
 36            masterVolume = 1f,
 37            voiceChatVolume = 1f,
 38            avatarSFXVolume = 1f,
 39            uiSFXVolume = 1f,
 40            sceneSFXVolume = 1f,
 41            musicVolume = 1f,
 42            chatSFXEnabled = true
 43        };
 44
 45        public DefaultSettingsFactory WithDefaultGeneralSettings(GeneralSettings settings)
 46        {
 047            defaultGeneralSettings = settings;
 048            return this;
 49        }
 50
 51        public DefaultSettingsFactory WithGraphicsQualitySettingsPresetPath(string path)
 52        {
 053            graphicsQualitySettingsPresetPath = path;
 054            return this;
 55        }
 56
 57        public Settings Build()
 58        {
 64059            var graphicsQualitySettingsPreset = Resources.Load<QualitySettingsData>(graphicsQualitySettingsPresetPath);
 64060            var audioMixer = Resources.Load<AudioMixer>(audioMixerPath);
 61
 64062            return new Settings(graphicsQualitySettingsPreset,
 63                audioMixer,
 64                CreateGraphicsQualityRepository(graphicsQualitySettingsPreset),
 65                CreateGeneralSettingsRepository(),
 66                CreateAudioSettingsRepository());
 67        }
 68
 69        private ProxySettingsRepository<AudioSettings> CreateAudioSettingsRepository()
 70        {
 64071            return new ProxySettingsRepository<AudioSettings>(
 72                new PlayerPrefsAudioSettingsRepository(
 73                    new PlayerPrefsSettingsByKey(AUDIO_SETTINGS_KEY),
 74                    defaultAudioSettings),
 75                new SettingsModule<AudioSettings>(
 76                    AUDIO_SETTINGS_KEY,
 77                    defaultAudioSettings));
 78        }
 79
 80        private ProxySettingsRepository<GeneralSettings> CreateGeneralSettingsRepository()
 81        {
 64082            return new ProxySettingsRepository<GeneralSettings>(
 83                new PlayerPrefsGeneralSettingsRepository(
 84                    new PlayerPrefsSettingsByKey(GENERAL_SETTINGS_KEY),
 85                    defaultGeneralSettings),
 86                new SettingsModule<GeneralSettings>(
 87                    GENERAL_SETTINGS_KEY,
 88                    defaultGeneralSettings));
 89        }
 90
 91        private ProxySettingsRepository<QualitySettings> CreateGraphicsQualityRepository(QualitySettingsData qualitySett
 92        {
 64093            return new ProxySettingsRepository<QualitySettings>(
 94                new PlayerPrefsQualitySettingsRepository(
 95                    new PlayerPrefsSettingsByKey(QUALITY_SETTINGS_KEY),
 96                    qualitySettingsPreset.defaultPreset),
 97                new SettingsModule<QualitySettings>(
 98                    QUALITY_SETTINGS_KEY,
 99                    qualitySettingsPreset.defaultPreset));
 100        }
 101    }
 102}