From 5db1ae22ba3681aac8526773bb82acdaff2ac0f1 Mon Sep 17 00:00:00 2001 From: MrKev312 <34964788+MrKev312@users.noreply.github.com> Date: Sat, 21 Dec 2024 22:59:34 +0100 Subject: [PATCH] Add PNG file processing and renaming logic Introduce code to process PNG files in MenuArtFolder. The code: 1. Renames files containing "_coach" to "_Coach_". 2. Renames files containing "_AlbumCoach" to "_Cover_AlbumCoach". Logs renaming operations and ensures new file names are unique. --- .../Converters/Images/MenuArtConverter.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/JustDanceEditor.Converter/Converters/Images/MenuArtConverter.cs b/JustDanceEditor.Converter/Converters/Images/MenuArtConverter.cs index 114b730..8792831 100644 --- a/JustDanceEditor.Converter/Converters/Images/MenuArtConverter.cs +++ b/JustDanceEditor.Converter/Converters/Images/MenuArtConverter.cs @@ -39,6 +39,31 @@ public static void ConvertMenuArt(ConvertUbiArtToUnity convert) } } + string[] pngFiles = Directory.GetFiles(convert.FileSystem.TempFolders.MenuArtFolder, "*.png"); + foreach (string pngFile in pngFiles) + { + string fileName = Path.GetFileNameWithoutExtension(pngFile); + // If {song}_coachx.png exists, rename it to {song}_Coach_x.png + if (fileName.Contains("_coach") && !fileName.Contains("_Coach_")) + { + Logger.Log($"Renaming {fileName} to {fileName.Replace("_coach", "_Coach_")}", LogLevel.Warning); + string newFileName = fileName.Replace("_coach", "_Coach_"); + string newFilePath = Path.Combine(convert.FileSystem.TempFolders.MenuArtFolder, newFileName + ".png"); + if (!File.Exists(newFilePath)) + File.Move(pngFile, newFilePath); + } + + // If {song}_AlbumCoach.png exists, rename it to {song}_Cover_AlbumCoach.png + if (fileName.Contains("_AlbumCoach", StringComparison.OrdinalIgnoreCase) && !fileName.Contains("_Cover_AlbumCoach", StringComparison.OrdinalIgnoreCase)) + { + Logger.Log($"Renaming {fileName} to {fileName.Replace("_AlbumCoach", "_Cover_AlbumCoach")}", LogLevel.Warning); + string newFileName = fileName.Replace("_AlbumCoach", "_Cover_AlbumCoach", StringComparison.OrdinalIgnoreCase); + string newFilePath = Path.Combine(convert.FileSystem.TempFolders.MenuArtFolder, newFileName + ".png"); + if (!File.Exists(newFilePath)) + File.Move(pngFile, newFilePath); + } + } + stopwatch.Stop(); Logger.Log($"Finished converting menu art files in {stopwatch.ElapsedMilliseconds}ms"); }