Skip to content

Commit

Permalink
Don't throw exception if I:R hair, skin or eye color palette is not f…
Browse files Browse the repository at this point in the history
…ound (#1565) #patch
  • Loading branch information
IhateTrains authored Oct 21, 2023
1 parent 58b0351 commit 873c1d0
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions ImperatorToCK3/CK3/Characters/DNAFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,39 @@ public sealed class DNAFactory {

public DNAFactory(ModFilesystem irModFS, ModFilesystem ck3ModFS) {
Logger.Debug("Reading color palettes...");
var irHairPalettePath = irModFS.GetActualFileLocation("gfx/portraits/hair_palette.dds") ??
throw new ConverterException("Could not find Imperator hair palette!");
irHairPalettePixels = new MagickImage(irHairPalettePath).GetPixels();

var ck3HairPalettePath = ck3ModFS.GetActualFileLocation("gfx/portraits/hair_palette.dds") ??
throw new ConverterException("Could not find CK3 hair palette!");
var ck3HairPalettePixels = new MagickImage(ck3HairPalettePath).GetPixels();
var irHairPalettePath = irModFS.GetActualFileLocation("gfx/portraits/hair_palette.dds");
if (irHairPalettePath is null) {
Logger.Warn("Could not find Imperator hair palette, using CK3 palette as fallback!");
irHairPalettePixels = ck3HairPalettePixels;
} else {
irHairPalettePixels = new MagickImage(irHairPalettePath).GetPixels();
}

var irSkinPalettePath = irModFS.GetActualFileLocation("gfx/portraits/skin_palette.dds") ??
throw new ConverterException("Could not find Imperator skin palette!");
irSkinPalettePixels = new MagickImage(irSkinPalettePath).GetPixels();
var ck3SkinPalettePath = ck3ModFS.GetActualFileLocation("gfx/portraits/skin_palette.dds") ??
throw new ConverterException("Could not find CK3 skin palette!");
var ck3SkinPalettePixels = new MagickImage(ck3SkinPalettePath).GetPixels();
var irSkinPalettePath = irModFS.GetActualFileLocation("gfx/portraits/skin_palette.dds");
if (irSkinPalettePath is null) {
Logger.Warn("Could not find Imperator skin palette, using CK3 palette as fallback!");
irSkinPalettePixels = ck3SkinPalettePixels;
} else {
irSkinPalettePixels = new MagickImage(irSkinPalettePath).GetPixels();
}

var irEyePalettePath = irModFS.GetActualFileLocation("gfx/portraits/eye_palette.dds") ??
throw new ConverterException("Could not find Imperator eye palette!");
irEyePalettePixels = new MagickImage(irEyePalettePath).GetPixels();
var ck3EyePalettePath = ck3ModFS.GetActualFileLocation("gfx/portraits/eye_palette.dds") ??
throw new ConverterException("Could not find CK3 eye palette!");
var ck3EyePalettePixels = new MagickImage(ck3EyePalettePath).GetPixels();
var irEyePalettePath = irModFS.GetActualFileLocation("gfx/portraits/eye_palette.dds");
if (irEyePalettePath is null) {
Logger.Warn("Could not find Imperator eye palette, using CK3 palette as fallback!");
irEyePalettePixels = ck3EyePalettePixels;
} else {
irEyePalettePixels = new MagickImage(irEyePalettePath).GetPixels();
}

Logger.Debug("Initializing genes database...");
ck3GenesDB = new GenesDB(ck3ModFS);
Expand Down

0 comments on commit 873c1d0

Please sign in to comment.