Esempio n. 1
0
        public static void GenerateSpoilerLog(string path)
        {
            if (MusicLookupTable.Count == 0 &&
                SoundLookupTable.Count == 0)
            {
                return;
            }

            using (StreamWriter sw = new StreamWriter(path))
            {
                sw.WriteLine($"Seed,{Properties.Settings.Default.Seed}");
                sw.WriteLine();

                sw.WriteLine($"Area Music,{Properties.Settings.Default.RandomizeAreaMusic}");
                sw.WriteLine($"Battle Music,{Properties.Settings.Default.RandomizeBattleMusic}");
                sw.WriteLine($"Ambient Noise,{Properties.Settings.Default.RandomizeAmbientNoise}");
                sw.WriteLine($"Cutscene Noise,{Properties.Settings.Default.RandomizeCutsceneNoise}");
                sw.WriteLine($"NPC Sounds,{Properties.Settings.Default.RandomizeNpcSounds}");
                sw.WriteLine($"Party Sounds,{Properties.Settings.Default.RandomizePartySounds}");
                sw.WriteLine($"Remove DMCA,{Properties.Settings.Default.RemoveDmcaMusic}");
                sw.WriteLine($"Mix NPC and Party,{Properties.Settings.Default.MixNpcAndPartySounds}");
                sw.WriteLine();

                if (MusicLookupTable.Any())
                {
                    var sortedLookup = MusicLookupTable.OrderBy(kvp => kvp.Key);
                    sw.WriteLine("Music");
                    sw.WriteLine("Original,Randomized");

                    foreach (var kvp in sortedLookup)
                    {
                        sw.WriteLine($"{kvp.Key},{kvp.Value}");
                    }

                    sw.WriteLine();
                }

                if (SoundLookupTable.Any())
                {
                    var sortedLookup = SoundLookupTable.OrderBy(kvp => kvp.Key);
                    sw.WriteLine("Sound");
                    sw.WriteLine("Original,Randomized");

                    foreach (var kvp in sortedLookup)
                    {
                        sw.WriteLine($"{kvp.Key},{kvp.Value}");
                    }

                    sw.WriteLine();
                }
            }
        }
Esempio n. 2
0
 private static void AddToMusicLookup(List <FileInfo> original, List <FileInfo> randomized)
 {
     for (int i = 0; i < original.Count; i++)
     {
         if (MusicLookupTable.ContainsKey(original[i].Name))
         {
             MusicLookupTable[original[i].Name] = randomized[i].Name;
         }
         else
         {
             MusicLookupTable.Add(original[i].Name, randomized[i].Name);
         }
     }
 }
Esempio n. 3
0
        public static void CreateSpoilerLog(XLWorkbook workbook)
        {
            if (MusicLookupTable.Count == 0 &&
                SoundLookupTable.Count == 0)
            {
                return;
            }
            var ws = workbook.Worksheets.Add("MusicSound");

            int i = 1;

            ws.Cell(i, 1).Value           = "Seed";
            ws.Cell(i, 2).Value           = Properties.Settings.Default.Seed;
            ws.Cell(i, 1).Style.Font.Bold = true;
            i++;

            Version version = typeof(StartForm).Assembly.GetName().Version;

            ws.Cell(i, 1).Value                      = "Version";
            ws.Cell(i, 1).Style.Font.Bold            = true;
            ws.Cell(i, 2).Value                      = $"v{version.Major}.{version.Minor}.{version.Build}";
            ws.Cell(i, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
            i += 2;     // Skip a row.

            // Music and Sound Randomization Settings
            ws.Cell(i, 1).Value = "Music/Sound Type";
            ws.Cell(i, 2).Value = "Rando Level";
            ws.Cell(i, 1).Style.Border.BottomBorder = XLBorderStyleValues.Thin;
            ws.Cell(i, 2).Style.Border.BottomBorder = XLBorderStyleValues.Thin;
            ws.Cell(i, 1).Style.Font.Bold           = true;
            ws.Cell(i, 2).Style.Font.Bold           = true;
            i++;

            var settings = new List <Tuple <string, string> >()
            {
                new Tuple <string, string>("Area Music", Properties.Settings.Default.RandomizeAreaMusic.ToString()),
                new Tuple <string, string>("Battle Music", Properties.Settings.Default.RandomizeBattleMusic.ToString()),
                new Tuple <string, string>("Ambient Noise", Properties.Settings.Default.RandomizeAmbientNoise.ToString()),
                new Tuple <string, string>("Cutscene Noise", Properties.Settings.Default.RandomizeCutsceneNoise.ToString()),
                new Tuple <string, string>("NPC Sounds", Properties.Settings.Default.RandomizeNpcSounds.ToString()),
                new Tuple <string, string>("Party Sounds", Properties.Settings.Default.RandomizePartySounds.ToString()),
                new Tuple <string, string>("Remove DMCA", Properties.Settings.Default.RemoveDmcaMusic.ToString()),
                new Tuple <string, string>("Mix NPC and Party", Properties.Settings.Default.MixNpcAndPartySounds.ToString()),
                new Tuple <string, string>("", ""),  // Skip a row.
            };

            foreach (var setting in settings)
            {
                ws.Cell(i, 1).Value             = setting.Item1;
                ws.Cell(i, 2).Value             = setting.Item2;
                ws.Cell(i, 1).Style.Font.Italic = true;
                i++;
            }

            // Music Shuffle
            if (MusicLookupTable.Any())
            {
                var sortedLookup = MusicLookupTable.OrderBy(kvp => kvp.Key);
                ws.Cell(i, 1).Value                      = "Music";
                ws.Cell(i, 1).Style.Font.Bold            = true;
                ws.Cell(i, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
                ws.Range(i, 1, i, 3).Merge();
                i++;

                ws.Cell(i, 1).Value = "Has Changed";
                ws.Cell(i, 2).Value = "Original";
                ws.Cell(i, 3).Value = "Randomized";
                ws.Cell(i, 1).Style.Border.BottomBorder = XLBorderStyleValues.Thin;
                ws.Cell(i, 2).Style.Border.BottomBorder = XLBorderStyleValues.Thin;
                ws.Cell(i, 3).Style.Border.BottomBorder = XLBorderStyleValues.Thin;
                ws.Cell(i, 1).Style.Font.Bold           = true;
                ws.Cell(i, 2).Style.Font.Bold           = true;
                ws.Cell(i, 3).Style.Font.Bold           = true;
                i++;

                foreach (var kvp in sortedLookup)
                {
                    var hasChanged = kvp.Key != kvp.Value;
                    ws.Cell(i, 1).Value = hasChanged;
                    ws.Cell(i, 2).Value = kvp.Key;
                    ws.Cell(i, 3).Value = kvp.Value;
                    if (hasChanged)
                    {
                        ws.Cell(i, 1).Style.Font.FontColor = XLColor.Green;
                    }
                    else
                    {
                        ws.Cell(i, 1).Style.Font.FontColor = XLColor.Red;
                    }
                    i++;
                }

                i++;    // Skip a row.
            }

            // Sound Shuffle
            if (SoundLookupTable.Any())
            {
                var sortedLookup = SoundLookupTable.OrderBy(kvp => kvp.Key);
                ws.Cell(i, 1).Value                      = "Sound";
                ws.Cell(i, 1).Style.Font.Bold            = true;
                ws.Cell(i, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
                ws.Range(i, 1, i, 3).Merge();
                i++;

                ws.Cell(i, 1).Value           = "Has Changed";
                ws.Cell(i, 2).Value           = "Original";
                ws.Cell(i, 3).Value           = "Randomized";
                ws.Cell(i, 1).Style.Font.Bold = true;
                ws.Cell(i, 2).Style.Font.Bold = true;
                ws.Cell(i, 3).Style.Font.Bold = true;
                i++;

                foreach (var kvp in sortedLookup)
                {
                    var hasChanged = kvp.Key != kvp.Value;
                    ws.Cell(i, 1).Value = hasChanged;
                    ws.Cell(i, 2).Value = kvp.Key;
                    ws.Cell(i, 3).Value = kvp.Value;
                    if (hasChanged)
                    {
                        ws.Cell(i, 1).Style.Font.FontColor = XLColor.Green;
                    }
                    else
                    {
                        ws.Cell(i, 1).Style.Font.FontColor = XLColor.Red;
                    }
                    i++;
                }
            }

            // Resize Columns
            ws.Column(1).AdjustToContents();
            ws.Column(2).AdjustToContents();
            ws.Column(3).AdjustToContents();
        }
Esempio n. 4
0
 internal static void Reset()
 {
     // Prepare lists for new randomization.
     MusicLookupTable.Clear();
     SoundLookupTable.Clear();
 }
Esempio n. 5
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);
            }
        }