Exemple #1
0
 /// <summary>
 /// Import the specified Zip file into the SoundManager sound scheme
 /// </summary>
 /// <param name="zipfile">Input Zip file</param>
 public static void Import(string zipfile)
 {
     using (ZipFile zip = ZipFile.Read(zipfile))
     {
         foreach (SoundEvent soundEvent in SoundEvent.GetAll())
         {
             if (TryExtract(zip, soundEvent.FileName, SoundEvent.DataDirectory) ||
                 TryExtract(zip, soundEvent.LegacyFileName, SoundEvent.DataDirectory, soundEvent.FileName))
             {
                 SoundScheme.Update(soundEvent, soundEvent.FilePath);
             }
             else
             {
                 SoundScheme.Remove(soundEvent);
             }
         }
         SchemeMeta.ResetAll();
         if (!TryExtract(zip, Path.GetFileName(SchemeMeta.SchemeImageFilePath), SoundEvent.DataDirectory))
         {
             TryExtract(zip, "visuel.bmp", SoundEvent.DataDirectory, Path.GetFileName(SchemeMeta.SchemeImageFilePath));
         }
         if (!TryExtract(zip, Path.GetFileName(SchemeMeta.SchemeInfoFilePath), SoundEvent.DataDirectory))
         {
             TryExtract(zip, "infos.ini", SoundEvent.DataDirectory, Path.GetFileName(SchemeMeta.SchemeInfoFilePath));
         }
         SchemeMeta.ReloadFromDisk();
         SoundScheme.Apply(SoundScheme.GetSchemeSoundManager(), Settings.MissingSoundUseDefault);
     }
 }
Exemple #2
0
        /// <summary>
        /// Setup will create and apply the SoundManager sound scheme, create data directory
        /// </summary>
        /// <param name="forceResetSounds">Also reset all sounds to their default values</param>
        /// <param name="systemIntegration">Also setup maximum system integration</param>
        public static void Setup(bool forceResetSounds, bool systemIntegration)
        {
            bool createDataDir = !Directory.Exists(DataFolder);

            if (createDataDir)
            {
                Directory.CreateDirectory(DataFolder);
            }

            SoundScheme.Setup();

            if (forceResetSounds || createDataDir)
            {
                foreach (SoundEvent soundEvent in SoundEvent.GetAll())
                {
                    SoundScheme.CopyDefault(soundEvent);
                }
            }

            SoundScheme.Apply(SoundScheme.GetSchemeSoundManager(), true);

            if (systemIntegration)
            {
                SoundArchive.AssocFiles();
                if (BgSoundPlayer.RequiredForThisWindowsVersion)
                {
                    BgSoundPlayer.RegisteredForStartup = true;
                    Process.Start(Application.ExecutablePath, ArgumentBgSoundPlayer);
                }
            }
        }
Exemple #3
0
 /// <summary>
 /// Replace the sound file associated with the specified sound event
 /// </summary>
 private void replaceSoundEvent(SoundEvent soundEvent, string soundFile)
 {
     try
     {
         SoundScheme.Update(soundEvent, soundFile);
         soundContextMenu_Play_Click(this, EventArgs.Empty);
         SoundScheme.Apply(SoundScheme.GetSchemeSoundManager(), Settings.MissingSoundUseDefault);
     }
     catch (Exception loadException)
     {
         MessageBox.Show(
             Translations.Get("sound_load_failed_text") + '\n' + loadException.Message,
             Translations.Get("sound_load_failed_title"),
             MessageBoxButtons.OK,
             MessageBoxIcon.Error
             );
     }
 }