Skip to content

Commit

Permalink
Bump PGCG.commonItems to 14.1.0 (#2246)
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains authored Oct 7, 2024
1 parent 7e5dfe1 commit 6b8aad2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
6 changes: 3 additions & 3 deletions ImperatorToCK3/Imperator/Defines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}
}

Expand Down
2 changes: 1 addition & 1 deletion ImperatorToCK3/ImperatorToCK3.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="PGCG.commonItems" Version="13.0.1" />
<PackageReference Include="PGCG.commonItems" Version="14.1.0" />
<PackageReference Include="PGCG.commonItems.SourceGenerators" Version="1.0.7"/>
<PackageReference Include="Polly" Version="8.4.2" />
<PackageReference Include="Roslynator.Analyzers" Version="4.12.7">
Expand Down
17 changes: 8 additions & 9 deletions ImperatorToCK3/Outputter/CoatOfArmsEmblemsOutputter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ private static void ConvertColoredEmblems(string outputModPath, ModFilesystem im
var acceptedExtensions = new HashSet<string>{ "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;
Expand Down Expand Up @@ -55,17 +55,16 @@ private static void CopyTexturedEmblems(string outputModPath, ModFilesystem impe
var acceptedExtensions = new HashSet<string>{ "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}!");
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions ImperatorToCK3/Outputter/CoatOfArmsOutputter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 6b8aad2

Please sign in to comment.