Skip to content

Commit

Permalink
[F] LoadJacketPng and RandomBgm crash when LocalAssets not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Sep 4, 2024
1 parent 84c59e2 commit 9f57d39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 7 additions & 6 deletions AquaMai/UX/LoadJacketPng.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ public static void LoadMusicPostfix(List<string> ____targetDirs)
}
}

foreach (var laFile in Directory.EnumerateFiles(Path.Combine(Environment.CurrentDirectory, "LocalAssets")))
{
var match = localAssetsJacketExt.Match(Path.GetFileName(laFile));
if (!match.Success) continue;
jacketPaths[match.Groups[1].Value] = laFile;
}
if (Directory.Exists(Path.Combine(Environment.CurrentDirectory, "LocalAssets")))
foreach (var laFile in Directory.EnumerateFiles(Path.Combine(Environment.CurrentDirectory, "LocalAssets")))
{
var match = localAssetsJacketExt.Match(Path.GetFileName(laFile));
if (!match.Success) continue;
jacketPaths[match.Groups[1].Value] = laFile;
}

MelonLogger.Msg($"Loaded {jacketPaths.Count} custom jacket images.");
}
Expand Down
4 changes: 3 additions & 1 deletion AquaMai/UX/RandomBgm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class RandomBgm
[HarmonyPatch(typeof(SoundManager), "Initialize")]
public static void Init()
{
if (!Directory.Exists(Path.Combine(Environment.CurrentDirectory, "LocalAssets", "Mai2Cue"))) return;
var files = Directory.EnumerateFiles(Path.Combine(Environment.CurrentDirectory, "LocalAssets", "Mai2Cue"));
foreach (var file in files)
{
Expand All @@ -34,6 +35,7 @@ public static void Init()
public static void PrePlay(ref SoundManager.AcbID acbID, int cueID)
{
if (acbID != SoundManager.AcbID.Default) return;
if (_acbs.Count == 0) return;
var cueIndex = (Cue)cueID;
switch (cueIndex)
{
Expand Down Expand Up @@ -69,4 +71,4 @@ public static bool PrePlayBGM(ref int target)
}
}
}
}
}

0 comments on commit 9f57d39

Please sign in to comment.