From 05fbdf9d74af9104108d9db0d70e1167d99abfb1 Mon Sep 17 00:00:00 2001 From: Wartori54 Date: Thu, 20 Jun 2024 00:21:35 +0200 Subject: [PATCH] Fix incorrect count with mods that have multiple yaml entries --- Celeste.Mod.mm/Mod/Everest/Everest.Loader.cs | 10 ++++++++++ Celeste.Mod.mm/Mod/Everest/EverestSplashHandler.cs | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/Celeste.Mod.mm/Mod/Everest/Everest.Loader.cs b/Celeste.Mod.mm/Mod/Everest/Everest.Loader.cs index 00d0bfdff..fb8fdbd40 100644 --- a/Celeste.Mod.mm/Mod/Everest/Everest.Loader.cs +++ b/Celeste.Mod.mm/Mod/Everest/Everest.Loader.cs @@ -322,6 +322,11 @@ public static void LoadZip(string archive) { }; if (multimetas != null) { + // When estimating the total mod count for the splash it is assumed that there will be exactly one + // ModuleMetadata per filesystem entry, which is a valid assumption most of the time, but very few + // mods do have multiple ModuleMetadatas in its everest.yaml, that's why we increase the total count + // late here when we realize that one may contain multiple + EverestSplashHandler.IncreaseTotalModCount(multimetas.Length-1); foreach (EverestModuleMetadata multimeta in multimetas) { multimeta.Multimeta = multimetas; if (contentMetaParent == null) @@ -404,6 +409,11 @@ public static void LoadDir(string dir) { }; if (multimetas != null) { + // When estimating the total mod count for the splash it is assumed that there will be exactly one + // ModuleMetadata per filesystem entry, which is a valid assumption most of the time, but very few + // mods do have multiple ModuleMetadatas in its everest.yaml, that's why we increase the total count + // late here when we realize that one may contain multiple + EverestSplashHandler.IncreaseTotalModCount(multimetas.Length-1); foreach (EverestModuleMetadata multimeta in multimetas) { multimeta.Multimeta = multimetas; if (contentMetaParent == null) diff --git a/Celeste.Mod.mm/Mod/Everest/EverestSplashHandler.cs b/Celeste.Mod.mm/Mod/Everest/EverestSplashHandler.cs index 424379e1f..cf77bd258 100644 --- a/Celeste.Mod.mm/Mod/Everest/EverestSplashHandler.cs +++ b/Celeste.Mod.mm/Mod/Everest/EverestSplashHandler.cs @@ -103,6 +103,10 @@ public static void SetSplashLoadingModCount(int modCount) { totalMods = modCount; } + public static void IncreaseTotalModCount(int amount) { + totalMods += amount; + } + public static void IncreaseLoadedModCount(string latestLoadedMod) { loadedMods++; SendMessageToSplash("#progress" + loadedMods + ";" + totalMods + ";" + latestLoadedMod);