diff --git a/ImperatorToCK3/Imperator/Defines.cs b/ImperatorToCK3/Imperator/Defines.cs index 1025bdddd..940e1a85e 100644 --- a/ImperatorToCK3/Imperator/Defines.cs +++ b/ImperatorToCK3/Imperator/Defines.cs @@ -13,17 +13,17 @@ public void LoadDefines(ModFilesystem imperatorModFs) { Logger.Info("Loading Imperator defines..."); var definesFiles = imperatorModFs.GetAllFilesInFolderRecursive("common/defines"); - foreach (var filePath in definesFiles) { + foreach (var fileInfo in definesFiles) { string jsonString = string.Empty; try { - jsonString = RakalyCaller.GetJson(filePath); + jsonString = RakalyCaller.GetJson(fileInfo.AbsolutePath); var jsonRoot = JsonDocument.Parse(jsonString).RootElement; if (jsonRoot.TryGetProperty("NUnit", out var unitProp) && unitProp.TryGetProperty("COHORT_SIZE", out var cohortSizeProp)) { CohortSize = cohortSizeProp.GetInt32(); } } catch (Exception e) { - Logger.Warn($"Failed to read defines from {filePath}:\n\tJSON string: {jsonString}\n\texception: {e}"); + Logger.Warn($"Failed to read defines from {fileInfo.AbsolutePath}:\n\tJSON string: {jsonString}\n\texception: {e}"); } } diff --git a/ImperatorToCK3/ImperatorToCK3.csproj b/ImperatorToCK3/ImperatorToCK3.csproj index 54ad5e58e..95294ae2d 100644 --- a/ImperatorToCK3/ImperatorToCK3.csproj +++ b/ImperatorToCK3/ImperatorToCK3.csproj @@ -42,7 +42,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/ImperatorToCK3/Outputter/CoatOfArmsEmblemsOutputter.cs b/ImperatorToCK3/Outputter/CoatOfArmsEmblemsOutputter.cs index a686b52fe..f90bd4dd7 100644 --- a/ImperatorToCK3/Outputter/CoatOfArmsEmblemsOutputter.cs +++ b/ImperatorToCK3/Outputter/CoatOfArmsEmblemsOutputter.cs @@ -15,11 +15,11 @@ private static void ConvertColoredEmblems(string outputModPath, ModFilesystem im var acceptedExtensions = new HashSet{ "dds", "tga", "png" }; var emblemFiles = imperatorModFS.GetAllFilesInFolderRecursive(coloredEmblemsFolder); - Parallel.ForEach(emblemFiles, filePath => { - if (!acceptedExtensions.Contains(CommonFunctions.GetExtension(filePath))) { + Parallel.ForEach(emblemFiles, fileInfo => { + if (!acceptedExtensions.Contains(CommonFunctions.GetExtension(fileInfo.RelativePath))) { return; } - CopyEmblem(filePath); + CopyEmblem(fileInfo.AbsolutePath); }); Logger.IncrementProgress(); return; @@ -55,17 +55,16 @@ private static void CopyTexturedEmblems(string outputModPath, ModFilesystem impe var acceptedExtensions = new HashSet{ "dds", "tga", "png" }; var emblemFiles = imperatorModFS.GetAllFilesInFolderRecursive(texturedEmblemsFolder); - foreach (var filePath in emblemFiles) { - if (!acceptedExtensions.Contains(CommonFunctions.GetExtension(filePath))) { + foreach (var fileInfo in emblemFiles) { + if (!acceptedExtensions.Contains(CommonFunctions.GetExtension(fileInfo.RelativePath))) { continue; } // Copy image to output path. - var fileName = CommonFunctions.TrimPath(filePath); - var outputPath = Path.Combine(outputModPath, "gfx/coat_of_arms/textured_emblems", fileName); - var wasCopied = SystemUtils.TryCopyFile(filePath, outputPath); + var outputPath = Path.Combine(outputModPath, texturedEmblemsFolder, fileInfo.RelativePath); + var wasCopied = SystemUtils.TryCopyFile(fileInfo.AbsolutePath, outputPath); if (!wasCopied) { - Logger.Warn($"Failed to copy textured emblem {fileName}!"); + Logger.Warn($"Failed to copy textured emblem {fileInfo.RelativePath}!"); } } } diff --git a/ImperatorToCK3/Outputter/CoatOfArmsOutputter.cs b/ImperatorToCK3/Outputter/CoatOfArmsOutputter.cs index e54a22f0b..9927fb218 100644 --- a/ImperatorToCK3/Outputter/CoatOfArmsOutputter.cs +++ b/ImperatorToCK3/Outputter/CoatOfArmsOutputter.cs @@ -53,10 +53,9 @@ public static void CopyCoaPatterns(ModFilesystem irModFS, string outputPath) { const string relativePatternsPath = "gfx/coat_of_arms/patterns"; var filePaths = irModFS.GetAllFilesInFolderRecursive(relativePatternsPath); - foreach (var filePath in filePaths) { - var index = filePath.IndexOf(relativePatternsPath, StringComparison.Ordinal); - var relativeFileOutputPath = filePath[index..]; - SystemUtils.TryCopyFile(filePath, Path.Combine(outputPath, relativeFileOutputPath)); + foreach (var fileInfo in filePaths) { + var destPath = Path.Combine(outputPath, relativePatternsPath, fileInfo.RelativePath); + SystemUtils.TryCopyFile(fileInfo.AbsolutePath, destPath); } Logger.IncrementProgress();