diff --git a/AudicaMod/src/CustomDifficultyName/CustomDifficultyNames.cs b/AudicaMod/src/CustomDifficultyName/CustomDifficultyNames.cs index 1954fce..8ecc121 100644 --- a/AudicaMod/src/CustomDifficultyName/CustomDifficultyNames.cs +++ b/AudicaMod/src/CustomDifficultyName/CustomDifficultyNames.cs @@ -11,7 +11,7 @@ namespace AudicaModding public class CustomDifficultyNames : MelonMod { public static Dictionary CustomDifficulties = new Dictionary(); - + public static bool NamesAlreadyLoaded = false; public class CustomNameData { public bool hasCustomExpertName = false; @@ -28,57 +28,60 @@ public class CustomNameData public static void LoadCustomNames() { - CustomDifficulties = new Dictionary(); - - foreach (SongList.SongData data in SongList.I.songs.ToArray()) + if (!NamesAlreadyLoaded) { - ZipArchive SongFiles = ZipFile.OpenRead(data.foundPath); + CustomDifficulties = new Dictionary(); - foreach (ZipArchiveEntry entry in SongFiles.Entries) + foreach (SongList.SongData data in SongList.I.songs.ToArray()) { - if (entry.Name == "song.desc") + ZipArchive SongFiles = ZipFile.OpenRead(data.foundPath); + + foreach (ZipArchiveEntry entry in SongFiles.Entries) { - Stream songData = entry.Open(); - StreamReader reader = new StreamReader(songData); - string descDump = reader.ReadToEnd(); - CustomNameData DifficultyNames = new CustomNameData(); - DifficultyNames = JSON.Load(descDump).Make(); + if (entry.Name == "song.desc") + { + Stream songData = entry.Open(); + StreamReader reader = new StreamReader(songData); + string descDump = reader.ReadToEnd(); + CustomNameData DifficultyNames = new CustomNameData(); + DifficultyNames = JSON.Load(descDump).Make(); - bool anyAreTrue = false; + bool anyAreTrue = false; - if (DifficultyNames.customExpert.Length > 0) - { - DifficultyNames.hasCustomExpertName = true; - anyAreTrue = true; - } + if (DifficultyNames.customExpert.Length > 0) + { + DifficultyNames.hasCustomExpertName = true; + anyAreTrue = true; + } - if (DifficultyNames.customAdvanced.Length > 0) - { - DifficultyNames.hasCustomAdvancedName = true; - anyAreTrue = true; - } + if (DifficultyNames.customAdvanced.Length > 0) + { + DifficultyNames.hasCustomAdvancedName = true; + anyAreTrue = true; + } - if (DifficultyNames.customModerate.Length > 0) - { - DifficultyNames.hasCustomModerateName = true; - anyAreTrue = true; - } + if (DifficultyNames.customModerate.Length > 0) + { + DifficultyNames.hasCustomModerateName = true; + anyAreTrue = true; + } - if (DifficultyNames.customBeginner.Length > 0) - { - DifficultyNames.hasCustomBeginnerName = true; - anyAreTrue = true; - } + if (DifficultyNames.customBeginner.Length > 0) + { + DifficultyNames.hasCustomBeginnerName = true; + anyAreTrue = true; + } - if (anyAreTrue) - CustomDifficulties[data.songID] = DifficultyNames; + if (anyAreTrue) + CustomDifficulties[data.songID] = DifficultyNames; + } } + NamesAlreadyLoaded = true; + SongFiles.Dispose(); } - - SongFiles.Dispose(); } } } diff --git a/AudicaMod/src/CustomDifficultyName/DifficultyHooks.cs b/AudicaMod/src/CustomDifficultyName/DifficultyHooks.cs index 3556ba2..5f9ce0e 100644 --- a/AudicaMod/src/CustomDifficultyName/DifficultyHooks.cs +++ b/AudicaMod/src/CustomDifficultyName/DifficultyHooks.cs @@ -15,7 +15,6 @@ public static IEnumerator ChangeNamesLP(LaunchPanel __instance) { yield return new WaitForSeconds(0.05f); - __instance.difficultySelect.gameObject.SetActive(false); var song = SongDataHolder.I.songData; CustomDifficultyNames.CustomNameData data; if (CustomDifficultyNames.CustomDifficulties.ContainsKey(song.songID)) @@ -76,9 +75,6 @@ public static IEnumerator ChangeNamesDS(DifficultySelect __instance) } } - /// - /// Author: MeepsKitten - /// [HarmonyPatch(typeof(LaunchPanel), "OnEnable", new Type[0])] private static class DisplayCustomNameLP {