Ejemplo n.º 1
0
        public static void sound_rando(KPaths paths)
        {
            // Prepare lists for new randomization.
            MusicLookupTable.Clear();
            SoundLookupTable.Clear();

            // Get file collections
            List <FileInfo> maxMusic   = new List <FileInfo>();
            List <FileInfo> maxSound   = new List <FileInfo>();
            List <FileInfo> musicFiles = new List <FileInfo>();
            List <FileInfo> soundFiles = new List <FileInfo>();

            if (Directory.Exists(paths.music_backup))
            {
                musicFiles = paths.FilesInMusicBackup.ToList();
            }
            if (Directory.Exists(paths.sounds_backup))
            {
                soundFiles = paths.FilesInSoundsBackup.ToList();
            }

            // Area Music
            List <FileInfo> areaMusic = new List <FileInfo>();

            foreach (var prefix in PrefixListAreaMusic)
            {
                areaMusic.AddRange(musicFiles.Where(f => f.Name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)));
            }

            if (Properties.Settings.Default.RemoveDmcaMusic)
            {
                areaMusic.RemoveAll(f => DmcaAreaMusic.Contains(f.Name));   // Remove DMCA music from the area list.
            }

            switch (Properties.Settings.Default.RandomizeAreaMusic)
            {
            case RandomizationLevel.Max:
                maxMusic.AddRange(areaMusic);
                break;

            case RandomizationLevel.Type:
                var randList = Randomize.RandomizeFiles(areaMusic, paths.music);
                AddToMusicLookup(areaMusic, randList);
                break;

            case RandomizationLevel.Subtype:
            case RandomizationLevel.None:
            default:
                break;
            }

            // Ambient Noise
            List <FileInfo> ambientNoiseMusic = new List <FileInfo>();

            foreach (var prefix in PrefixListNoise)
            {
                ambientNoiseMusic.AddRange(musicFiles.Where(f => f.Name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)));
            }

            List <FileInfo> ambientNoiseSound = new List <FileInfo>();

            foreach (var prefix in PrefixListNoise)
            {
                ambientNoiseSound.AddRange(soundFiles.Where(f => f.Name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)));
            }

            switch (Properties.Settings.Default.RandomizeAmbientNoise)
            {
            case RandomizationLevel.Max:
                maxMusic.AddRange(ambientNoiseMusic);
                maxSound.AddRange(ambientNoiseSound);
                break;

            case RandomizationLevel.Type:
                var randList = Randomize.RandomizeFiles(ambientNoiseMusic, paths.music);
                AddToMusicLookup(ambientNoiseMusic, randList);

                randList = Randomize.RandomizeFiles(ambientNoiseSound, paths.sounds);
                AddToSoundLookup(ambientNoiseSound, randList);
                break;

            case RandomizationLevel.Subtype:
            case RandomizationLevel.None:
            default:
                break;
            }

            // Battle Music
            List <FileInfo> battleMusic    = new List <FileInfo>(musicFiles.Where(f => RegexBattleMusic.IsMatch(f.Name)));
            List <FileInfo> battleMusicEnd = new List <FileInfo>(soundFiles.Where(f => RegexBattleMusic.IsMatch(f.Name)));

            switch (Properties.Settings.Default.RandomizeBattleMusic)
            {
            case RandomizationLevel.Max:
                maxMusic.AddRange(battleMusic);
                maxSound.AddRange(battleMusicEnd);
                break;

            case RandomizationLevel.Type:
                var randList = Randomize.RandomizeFiles(battleMusic, paths.music);
                AddToMusicLookup(battleMusic, randList);

                randList = Randomize.RandomizeFiles(battleMusicEnd, paths.sounds);
                AddToSoundLookup(battleMusicEnd, randList);
                break;

            case RandomizationLevel.Subtype:
            case RandomizationLevel.None:
            default:
                break;
            }

            // Cutscene Noise
            List <FileInfo> cutsceneNoise = new List <FileInfo>(musicFiles.Where(f => RegexCutscene.IsMatch(f.Name)));

            cutsceneNoise.RemoveAll(f => f.Name.StartsWith("57.")); // Remove specific exception

            switch (Properties.Settings.Default.RandomizeCutsceneNoise)
            {
            case RandomizationLevel.Max:
                maxMusic.AddRange(cutsceneNoise);
                break;

            case RandomizationLevel.Type:
                var randList = Randomize.RandomizeFiles(cutsceneNoise, paths.music);
                AddToMusicLookup(cutsceneNoise, randList);
                break;

            case RandomizationLevel.Subtype:
            case RandomizationLevel.None:
            default:
                break;
            }

            // Check if NPC and Party Sounds are combined
            List <FileInfo> npcSounds   = new List <FileInfo>(soundFiles.Where(f => RegexNPCSound.IsMatch(f.Name)));
            List <FileInfo> partySounds = new List <FileInfo>(soundFiles.Where(f => RegexPartySound.IsMatch(f.Name)));

            //if (MixNpcAndPartySounds) // Functionality Disabled
            //{
            //    npcSounds.AddRange(partySounds);
            //}
            //else
            {
                // Party Sounds (if not mixing)
                switch (Properties.Settings.Default.RandomizePartySounds)
                {
                case RandomizationLevel.Max:
                    maxSound.AddRange(partySounds);
                    break;

                case RandomizationLevel.Type:
                    var randList = Randomize.RandomizeFiles(partySounds, paths.sounds);
                    AddToSoundLookup(partySounds, randList);
                    break;

                case RandomizationLevel.Subtype:
                    RandomizeSoundActions(partySounds, paths.sounds);
                    break;

                case RandomizationLevel.None:
                default:
                    break;
                }
            }

            //// NPC Sounds (or both if mixing) // Functionality Disabled
            //switch (RandomizeNpcSounds)
            //{
            //    case RandomizationLevel.Max:
            //        maxSound.AddRange(npcSounds);
            //        break;
            //    case RandomizationLevel.Type:
            //        Randomize.RandomizeFiles(npcSounds, SoundsPath);
            //        break;
            //    case RandomizationLevel.Subtype:
            //        RandomizeSoundActions(npcSounds, SoundsPath);
            //        break;
            //    case RandomizationLevel.None:
            //    default:
            //        break;
            //}

            // Max Randomizations
            if (maxMusic.Any())
            {
                var randList = Randomize.RandomizeFiles(maxMusic, paths.music);
                AddToMusicLookup(maxMusic, randList);
            }
            if (maxSound.Any())
            {
                var randList = Randomize.RandomizeFiles(maxSound, paths.sounds);
                AddToSoundLookup(maxSound, randList);
            }

            // Overwrite DMCA music with alternatives
            if (Properties.Settings.Default.RemoveDmcaMusic)
            {
                var orig = new List <FileInfo>();
                var rand = new List <FileInfo>();
                foreach (var fi in musicFiles.Where(f => DmcaAreaMusic.Contains(f.Name)))
                {
                    var replacement = areaMusic[Randomize.Rng.Next(areaMusic.Count)];
                    File.Copy(replacement.FullName, Path.Combine(paths.music, fi.Name), true);

                    orig.Add(fi);
                    rand.Add(replacement);
                }
                AddToMusicLookup(orig, rand);
            }
        }
Ejemplo n.º 2
0
        public static void sound_rando(KPaths paths)
        {
            var musicFiles = paths.FilesInMusicBackup;
            var soundFiles = paths.FilesInSoundsBackup;

            // Get file collections
            List <FileInfo> maxMusic = new List <FileInfo>();
            List <FileInfo> maxSound = new List <FileInfo>();

            // Area Music
            List <FileInfo> areaMusic = new List <FileInfo>();

            foreach (var prefix in PrefixListAreaMusic)
            {
                areaMusic.AddRange(musicFiles.Where(f => f.Name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)));
            }

            switch ((RandomizationLevel)Properties.Settings.Default.RandomizeAreaMusic)
            {
            case RandomizationLevel.Max:
                maxMusic.AddRange(areaMusic);
                break;

            case RandomizationLevel.Type:
                Randomize.RandomizeFiles(areaMusic, paths.music);
                break;

            case RandomizationLevel.Subtype:
            case RandomizationLevel.None:
            default:
                break;
            }

            // Ambient Noise
            List <FileInfo> ambientNoiseMusic = new List <FileInfo>();

            foreach (var prefix in PrefixListNoise)
            {
                ambientNoiseMusic.AddRange(musicFiles.Where(f => f.Name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)));
            }

            List <FileInfo> ambientNoiseSound = new List <FileInfo>();

            foreach (var prefix in PrefixListNoise)
            {
                ambientNoiseSound.AddRange(soundFiles.Where(f => f.Name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)));
            }

            switch ((RandomizationLevel)Properties.Settings.Default.RandomizeAmbientNoise)
            {
            case RandomizationLevel.Max:
                maxMusic.AddRange(ambientNoiseMusic);
                maxSound.AddRange(ambientNoiseSound);
                break;

            case RandomizationLevel.Type:
                Randomize.RandomizeFiles(ambientNoiseMusic, paths.music);
                Randomize.RandomizeFiles(ambientNoiseSound, paths.sounds);
                break;

            case RandomizationLevel.Subtype:
            case RandomizationLevel.None:
            default:
                break;
            }

            // Battle Music
            List <FileInfo> battleMusic    = new List <FileInfo>(musicFiles.Where(f => RegexBattleMusic.IsMatch(f.Name)));
            List <FileInfo> battleMusicEnd = new List <FileInfo>(soundFiles.Where(f => RegexBattleMusic.IsMatch(f.Name)));

            switch ((RandomizationLevel)Properties.Settings.Default.RandomizeBattleMusic)
            {
            case RandomizationLevel.Max:
                maxMusic.AddRange(battleMusic);
                maxSound.AddRange(battleMusicEnd);
                break;

            case RandomizationLevel.Type:
                Randomize.RandomizeFiles(battleMusic, paths.music);
                Randomize.RandomizeFiles(battleMusicEnd, paths.sounds);
                break;

            case RandomizationLevel.Subtype:
            case RandomizationLevel.None:
            default:
                break;
            }

            // Cutscene Noise
            List <FileInfo> cutsceneNoise = new List <FileInfo>(musicFiles.Where(f => RegexCutscene.IsMatch(f.Name)));

            cutsceneNoise.RemoveAll(f => f.Name.StartsWith("57.")); // Remove specific exception

            switch ((RandomizationLevel)Properties.Settings.Default.RandomizeCutsceneNoise)
            {
            case RandomizationLevel.Max:
                maxMusic.AddRange(cutsceneNoise);
                break;

            case RandomizationLevel.Type:
                Randomize.RandomizeFiles(cutsceneNoise, paths.music);
                break;

            case RandomizationLevel.Subtype:
            case RandomizationLevel.None:
            default:
                break;
            }

            // Check if NPC and Party Sounds are combined
            List <FileInfo> npcSounds   = new List <FileInfo>(soundFiles.Where(f => RegexNPCSound.IsMatch(f.Name)));
            List <FileInfo> partySounds = new List <FileInfo>(soundFiles.Where(f => RegexPartySound.IsMatch(f.Name)));

            //if (MixNpcAndPartySounds) // Functionality Disabled
            //{
            //    npcSounds.AddRange(partySounds);
            //}
            //else
            {
                // Party Sounds (if not mixing)
                switch ((RandomizationLevel)Properties.Settings.Default.RandomizePartySounds)
                {
                case RandomizationLevel.Max:
                    maxSound.AddRange(partySounds);
                    break;

                case RandomizationLevel.Type:
                    Randomize.RandomizeFiles(partySounds, paths.sounds);
                    break;

                case RandomizationLevel.Subtype:
                    RandomizeSoundActions(partySounds, paths.sounds);
                    break;

                case RandomizationLevel.None:
                default:
                    break;
                }
            }

            //// NPC Sounds (or both if mixing) // Functionality Disabled
            //switch (RandomizeNpcSounds)
            //{
            //    case RandomizationLevel.Max:
            //        maxSound.AddRange(npcSounds);
            //        break;
            //    case RandomizationLevel.Type:
            //        Randomize.RandomizeFiles(npcSounds, SoundsPath);
            //        break;
            //    case RandomizationLevel.Subtype:
            //        RandomizeSoundActions(npcSounds, SoundsPath);
            //        break;
            //    case RandomizationLevel.None:
            //    default:
            //        break;
            //}

            // Max Randomizations
            if (maxMusic.Any())
            {
                Randomize.RandomizeFiles(maxMusic, paths.music);
            }
            if (maxSound.Any())
            {
                Randomize.RandomizeFiles(maxSound, paths.sounds);
            }
        }