Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump PGCG.commonItems to 14.1.0 #2246

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading