Skip to content

Commit

Permalink
Add PNG file processing and renaming logic
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MrKev312 committed Dec 21, 2024
1 parent 2a42331 commit 5db1ae2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions JustDanceEditor.Converter/Converters/Images/MenuArtConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down

0 comments on commit 5db1ae2

Please sign in to comment.