From ca88091cd1d3795656f9ff02f955ad83fc84ea89 Mon Sep 17 00:00:00 2001 From: Miepee Date: Sat, 24 Dec 2022 21:31:02 +0100 Subject: [PATCH] Hopefully fix duplicate songs on Android --- AM2RLauncher/AM2RLauncherLib/Profile.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/AM2RLauncher/AM2RLauncherLib/Profile.cs b/AM2RLauncher/AM2RLauncherLib/Profile.cs index 625048d..d73f20c 100644 --- a/AM2RLauncher/AM2RLauncherLib/Profile.cs +++ b/AM2RLauncher/AM2RLauncherLib/Profile.cs @@ -621,13 +621,35 @@ public static class Profile progress.Report(28); // Add datafiles: 1.1, hq music if wished for, new datafiles, am2r.ini + // Also we need to lowercase the songs on android string workingDir = $"{tempDir}/AM2RWrapper/assets"; ZipFile.ExtractToDirectory(Core.AM2R11File, workingDir); if (useHqMusic) HelperMethods.DirectoryCopy($"{Core.PatchDataPath}/data/HDR_HQ_in-game_music", workingDir); + + void LowercaseAllOggs(string path) + { + foreach (var file in new DirectoryInfo(path).GetFiles().Where(f => f.Extension.ToLower() == ".ogg")) + { + if (file.Name.ToLower() == file.Name) continue; + + var filedir = file.DirectoryName; + var origName = file.Name; + var finalPath = filedir + "/" + origName.ToLower(); + file.MoveTo(filedir + "/" + file.Name + "_"); + if (File.Exists(finalPath)) + File.Delete(finalPath); + file.MoveTo(finalPath); + } + } + + LowercaseAllOggs(workingDir); HelperMethods.DirectoryCopy($"{dataPath}/files_to_copy", workingDir); + // And also once after copying the mod songs, as there may be new ones in there + LowercaseAllOggs(workingDir); + // Yes, I'm aware this is dumb. If you've got any better ideas for how to copy a seemingly randomly named .ini from this folder to the APK, please let me know. foreach (FileInfo file in new DirectoryInfo(dataPath).GetFiles().Where(f => f.Name.EndsWith("ini")))