Exemple #1
0
        public void ReloadVolumeLevels()
        {
            string     cleanPath = SharedContentManager.GetCleanPath(this.CMProvider.Global.RootDirectory + "\\Sounds" + "\\SoundLevels.sdl");
            FileStream fileStream;

            try
            {
                fileStream = new FileStream(cleanPath, FileMode.Open, FileAccess.Read);
            }
            catch (Exception ex)
            {
                if (ex is FileNotFoundException || ex is DirectoryNotFoundException)
                {
                    Logger.Log("Sound Levels", LogSeverity.Warning, "Could not find levels file, ignoring...");
                    fileStream = (FileStream)null;
                }
                else
                {
                    Logger.Log("Sound Levels", LogSeverity.Warning, ex.Message);
                    return;
                }
            }
            if (fileStream == null)
            {
                this.VolumeLevels = new VolumeLevels();
            }
            else
            {
                this.VolumeLevels = SdlSerializer.Deserialize <VolumeLevels>(new StreamReader((Stream)fileStream));
            }
        }