| | 1 | | using UnityEngine; |
| | 2 | | using UnityEngine.Audio; |
| | 3 | |
|
| | 4 | | namespace 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 | |
|
| 640 | 12 | | private string graphicsQualitySettingsPresetPath = "ScriptableObjects/QualitySettingsData"; |
| 640 | 13 | | private string audioMixerPath = "AudioMixer"; |
| | 14 | |
|
| 640 | 15 | | 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 | |
|
| 640 | 34 | | 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 | | { |
| 0 | 47 | | defaultGeneralSettings = settings; |
| 0 | 48 | | return this; |
| | 49 | | } |
| | 50 | |
|
| | 51 | | public DefaultSettingsFactory WithGraphicsQualitySettingsPresetPath(string path) |
| | 52 | | { |
| 0 | 53 | | graphicsQualitySettingsPresetPath = path; |
| 0 | 54 | | return this; |
| | 55 | | } |
| | 56 | |
|
| | 57 | | public Settings Build() |
| | 58 | | { |
| 640 | 59 | | var graphicsQualitySettingsPreset = Resources.Load<QualitySettingsData>(graphicsQualitySettingsPresetPath); |
| 640 | 60 | | var audioMixer = Resources.Load<AudioMixer>(audioMixerPath); |
| | 61 | |
|
| 640 | 62 | | return new Settings(graphicsQualitySettingsPreset, |
| | 63 | | audioMixer, |
| | 64 | | CreateGraphicsQualityRepository(graphicsQualitySettingsPreset), |
| | 65 | | CreateGeneralSettingsRepository(), |
| | 66 | | CreateAudioSettingsRepository()); |
| | 67 | | } |
| | 68 | |
|
| | 69 | | private ProxySettingsRepository<AudioSettings> CreateAudioSettingsRepository() |
| | 70 | | { |
| 640 | 71 | | 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 | | { |
| 640 | 82 | | 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 | | { |
| 640 | 93 | | 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 | | } |