diff --git a/ImperatorToCK3.UnitTests/CK3/Characters/CharacterCollectionTests.cs b/ImperatorToCK3.UnitTests/CK3/Characters/CharacterCollectionTests.cs index 7cb68c37e..c98c46c01 100644 --- a/ImperatorToCK3.UnitTests/CK3/Characters/CharacterCollectionTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Characters/CharacterCollectionTests.cs @@ -58,7 +58,7 @@ static CharacterCollectionTests() { irRegionMapper = new ImperatorRegionMapper(areas); irRegionMapper.LoadRegions(irModFS, colorFactory); - cultures = new CultureCollection(colorFactory, new PillarCollection()); + cultures = new CultureCollection(colorFactory, new PillarCollection(colorFactory)); } [Fact] diff --git a/ImperatorToCK3.UnitTests/CK3/Cultures/CultureCollectionTests.cs b/ImperatorToCK3.UnitTests/CK3/Cultures/CultureCollectionTests.cs index b7e8caa77..8c0bc39fd 100644 --- a/ImperatorToCK3.UnitTests/CK3/Cultures/CultureCollectionTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Cultures/CultureCollectionTests.cs @@ -14,7 +14,7 @@ public class CultureCollectionTests { private static readonly ColorFactory ColorFactory = new(); static CultureCollectionTests() { - Pillars = new PillarCollection { new("test_heritage", new BufferedReader("type = heritage")) }; + Pillars = new PillarCollection(ColorFactory) { new("test_heritage", new PillarData { Type = "heritage" }) }; } [Fact] diff --git a/ImperatorToCK3.UnitTests/CK3/Cultures/PillarCollectionTests.cs b/ImperatorToCK3.UnitTests/CK3/Cultures/PillarCollectionTests.cs new file mode 100644 index 000000000..191e20ae2 --- /dev/null +++ b/ImperatorToCK3.UnitTests/CK3/Cultures/PillarCollectionTests.cs @@ -0,0 +1,30 @@ +using commonItems.Mods; +using ImperatorToCK3.CK3.Cultures; +using System; +using System.IO; +using Xunit; + +namespace ImperatorToCK3.UnitTests.CK3.Cultures; + +[Collection("Sequential")] +[CollectionDefinition("Sequential", DisableParallelization = true)] +public class PillarCollectionTests { + [Fact] + public void WarningIsLoggedWhenPillarDataIsMissingType() { + Directory.CreateDirectory("pillars_test"); + Directory.CreateDirectory("pillars_test/common"); + Directory.CreateDirectory("pillars_test/common/culture"); + Directory.CreateDirectory("pillars_test/common/culture/pillars"); + var pillarsFile = File.CreateText("pillars_test/common/culture/pillars/test_pillars.txt"); + pillarsFile.WriteLine("pillar_without_type = {}"); + pillarsFile.Close(); + + var modFS = new ModFilesystem("pillars_test", Array.Empty()); + var collection = new PillarCollection(new commonItems.Colors.ColorFactory()); + + var consoleOut = new StringWriter(); + Console.SetOut(consoleOut); + collection.LoadPillars(modFS); + Assert.Contains("[WARN] Pillar pillar_without_type has no type defined! Skipping.", consoleOut.ToString()); + } +} \ No newline at end of file diff --git a/ImperatorToCK3.UnitTests/CK3/Cultures/PillarTests.cs b/ImperatorToCK3.UnitTests/CK3/Cultures/PillarTests.cs index b00166dd3..006e35a69 100644 --- a/ImperatorToCK3.UnitTests/CK3/Cultures/PillarTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Cultures/PillarTests.cs @@ -1,22 +1,12 @@ -using commonItems; using ImperatorToCK3.CK3.Cultures; -using ImperatorToCK3.Exceptions; using Xunit; namespace ImperatorToCK3.UnitTests.CK3.Cultures; public class PillarTests { - [Fact] - public void ExceptionIsThrownOnMissingType() { - var reader = new BufferedReader("= {}"); - var exception = Assert.Throws(() => new Pillar("test_pillar", reader)); - Assert.Equal("Cultural pillar test_pillar has no type defined!", exception.Message); - } - [Fact] public void PillarIsCorrectlyInitialized() { - var reader = new BufferedReader("= { type = test_type }"); - var pillar = new Pillar("test_pillar", reader); + var pillar = new Pillar("test_pillar", new PillarData { Type = "test_type" }); Assert.Equal("test_pillar", pillar.Id); Assert.Equal("test_type", pillar.Type); } diff --git a/ImperatorToCK3.UnitTests/CK3/Provinces/ProvincesTests.cs b/ImperatorToCK3.UnitTests/CK3/Provinces/ProvincesTests.cs index 248495b0f..ad4e4ff23 100644 --- a/ImperatorToCK3.UnitTests/CK3/Provinces/ProvincesTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Provinces/ProvincesTests.cs @@ -105,7 +105,7 @@ public void PrimaryImperatorProvinceIsProperlyDeterminedForCK3Province() { areas.LoadAreas(irModFS, irWorld.Provinces); var irRegionMapper = new ImperatorRegionMapper(areas); irRegionMapper.LoadRegions(irModFS, new ColorFactory()); - var cultures = new CultureCollection(new ColorFactory(), new PillarCollection()); + var cultures = new CultureCollection(new ColorFactory(), new PillarCollection(new ColorFactory())); var cultureMapper = new CultureMapper(irRegionMapper, ck3RegionMapper, cultures); var religions = new ReligionCollection(titles); var religionMapper = new ReligionMapper(religions, irRegionMapper, ck3RegionMapper); diff --git a/ImperatorToCK3.UnitTests/CK3/Titles/LandedTitlesTests.cs b/ImperatorToCK3.UnitTests/CK3/Titles/LandedTitlesTests.cs index f4b54f275..c9677044a 100644 --- a/ImperatorToCK3.UnitTests/CK3/Titles/LandedTitlesTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Titles/LandedTitlesTests.cs @@ -56,8 +56,9 @@ static LandedTitlesTests() { } public LandedTitlesTests() { - PillarCollection pillars = new(); - cultures = new CultureCollection(new ColorFactory(), pillars); + var colorFactory = new ColorFactory(); + PillarCollection pillars = new(colorFactory); + cultures = new CultureCollection(colorFactory, pillars); } [Fact] diff --git a/ImperatorToCK3.UnitTests/CK3/Titles/RulerTermTests.cs b/ImperatorToCK3.UnitTests/CK3/Titles/RulerTermTests.cs index 6a5d06d79..70073a74b 100644 --- a/ImperatorToCK3.UnitTests/CK3/Titles/RulerTermTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Titles/RulerTermTests.cs @@ -56,7 +56,7 @@ public void ImperatorRulerTermIsCorrectlyConverted() { govMapper, new LocDB("english"), new ReligionMapper(ck3Religions, irRegionMapper, ck3RegionMapper), - new CultureMapper(irRegionMapper, ck3RegionMapper, new CultureCollection(new ColorFactory(), new PillarCollection())), + new CultureMapper(irRegionMapper, ck3RegionMapper, new CultureCollection(new ColorFactory(), new PillarCollection(new ColorFactory()))), new NicknameMapper("TestFiles/configurables/nickname_map.txt"), new ProvinceMapper(), new Configuration() diff --git a/ImperatorToCK3.UnitTests/CK3/Titles/TitleTests.cs b/ImperatorToCK3.UnitTests/CK3/Titles/TitleTests.cs index fbc5590c2..e72d9245f 100644 --- a/ImperatorToCK3.UnitTests/CK3/Titles/TitleTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Titles/TitleTests.cs @@ -56,7 +56,7 @@ private class TitleBuilder { private DefiniteFormMapper definiteFormMapper = new("TestFiles/configurables/definite_form_names.txt"); private readonly ReligionMapper religionMapper; - private readonly CultureMapper cultureMapper = new(irRegionMapper, new CK3RegionMapper(), new CultureCollection(new ColorFactory(), new PillarCollection())); + private readonly CultureMapper cultureMapper = new(irRegionMapper, new CK3RegionMapper(), new CultureCollection(new ColorFactory(), new PillarCollection(new ColorFactory()))); private readonly NicknameMapper nicknameMapper = new("TestFiles/configurables/nickname_map.txt"); private readonly Date ck3BookmarkDate = new(867, 1, 1); private readonly CharacterCollection characters = new(); diff --git a/ImperatorToCK3.UnitTests/Imperator/Countries/CountryNameTests.cs b/ImperatorToCK3.UnitTests/Imperator/Countries/CountryNameTests.cs index 002bbb649..3647fdc61 100644 --- a/ImperatorToCK3.UnitTests/Imperator/Countries/CountryNameTests.cs +++ b/ImperatorToCK3.UnitTests/Imperator/Countries/CountryNameTests.cs @@ -110,8 +110,9 @@ public void GetNameLocBlockCorrectlyHandlesCompositeNames() { provLocBlock["german"] = "Hormirzad"; var nameLocBlock = countryName.GetNameLocBlock(locDB, []); - Assert.Equal("Memphite Hormirzad", nameLocBlock!["english"]); - Assert.Equal("Memphit Hormirzad", nameLocBlock!["german"]); + Assert.NotNull(nameLocBlock); + Assert.Equal("Memphite Hormirzad", nameLocBlock["english"]); + Assert.Equal("Memphit Hormirzad", nameLocBlock["german"]); } [Fact] diff --git a/ImperatorToCK3.UnitTests/Mappers/TagTitle/TagTitleMapperTests.cs b/ImperatorToCK3.UnitTests/Mappers/TagTitle/TagTitleMapperTests.cs index 4bd56ada1..83274a85c 100644 --- a/ImperatorToCK3.UnitTests/Mappers/TagTitle/TagTitleMapperTests.cs +++ b/ImperatorToCK3.UnitTests/Mappers/TagTitle/TagTitleMapperTests.cs @@ -38,7 +38,7 @@ public class TagTitleMapperTests { private static readonly ColorFactory ColorFactory = new(); static TagTitleMapperTests() { - var pillars = new PillarCollection(); + var pillars = new PillarCollection(ColorFactory); cultures = new CultureCollection(ColorFactory, pillars); } diff --git a/ImperatorToCK3.UnitTests/Outputter/CoatOfArmsOutputterTests.cs b/ImperatorToCK3.UnitTests/Outputter/CoatOfArmsOutputterTests.cs index 82f32b29d..8c1e2c152 100644 --- a/ImperatorToCK3.UnitTests/Outputter/CoatOfArmsOutputterTests.cs +++ b/ImperatorToCK3.UnitTests/Outputter/CoatOfArmsOutputterTests.cs @@ -60,7 +60,7 @@ public void CoaIsOutputtedForCountryWithFlagSet() { new SuccessionLawMapper(), new DefiniteFormMapper(), new ReligionMapper(ck3Religions, irRegionMapper, ck3RegionMapper), - new CultureMapper(irRegionMapper, ck3RegionMapper, new CultureCollection(new ColorFactory(), new PillarCollection())), + new CultureMapper(irRegionMapper, ck3RegionMapper, new CultureCollection(new ColorFactory(), new PillarCollection(new ColorFactory()))), new NicknameMapper(), new CharacterCollection(), new Date(400, 1, 1), @@ -102,7 +102,7 @@ public void CoaIsNotOutputtedForCountryWithoutFlagSet() { new SuccessionLawMapper(), new DefiniteFormMapper(), new ReligionMapper(ck3Religions, irRegionMapper, ck3RegionMapper), - new CultureMapper(irRegionMapper, ck3RegionMapper, new CultureCollection(new ColorFactory(), new PillarCollection())), + new CultureMapper(irRegionMapper, ck3RegionMapper, new CultureCollection(new ColorFactory(), new PillarCollection(new ColorFactory()))), new NicknameMapper(), new CharacterCollection(), new Date(400, 1, 1), diff --git a/ImperatorToCK3.UnitTests/Outputter/DynastiesOutputterTests.cs b/ImperatorToCK3.UnitTests/Outputter/DynastiesOutputterTests.cs index c1cca8f8c..51572bf2c 100644 --- a/ImperatorToCK3.UnitTests/Outputter/DynastiesOutputterTests.cs +++ b/ImperatorToCK3.UnitTests/Outputter/DynastiesOutputterTests.cs @@ -29,7 +29,8 @@ public void DynastiesAreOutputted() { AreaCollection areas = new(); ImperatorRegionMapper irRegionMapper = new(areas); irRegionMapper.LoadRegions(irModFS, new ColorFactory()); - CultureMapper cultureMapper = new(irRegionMapper, new CK3RegionMapper(), new CultureCollection(new ColorFactory(), new PillarCollection())); + var colorFactory = new ColorFactory(); + CultureMapper cultureMapper = new(irRegionMapper, new CK3RegionMapper(), new CultureCollection(colorFactory, new PillarCollection(colorFactory))); var characters = new CharacterCollection(); var dynasties = new DynastyCollection(); diff --git a/ImperatorToCK3.UnitTests/TestHelpers/TestCK3CultureCollection.cs b/ImperatorToCK3.UnitTests/TestHelpers/TestCK3CultureCollection.cs index 09a73fba6..5c4c71e7b 100644 --- a/ImperatorToCK3.UnitTests/TestHelpers/TestCK3CultureCollection.cs +++ b/ImperatorToCK3.UnitTests/TestHelpers/TestCK3CultureCollection.cs @@ -6,10 +6,10 @@ namespace ImperatorToCK3.UnitTests.TestHelpers; public class TestCK3CultureCollection() : CultureCollection(new ColorFactory(), TestCulturalPillars) { - private static readonly PillarCollection TestCulturalPillars = new(); + private static readonly PillarCollection TestCulturalPillars = new(new ColorFactory()); static TestCK3CultureCollection() { - TestCulturalPillars.Add(new Pillar("test_heritage", new BufferedReader("type = heritage"))); + TestCulturalPillars.Add(new Pillar("test_heritage", new PillarData { Type = "heritage" })); } public void GenerateTestCulture(string id) { diff --git a/ImperatorToCK3/CK3/Cultures/Pillar.cs b/ImperatorToCK3/CK3/Cultures/Pillar.cs index 897880e90..439c4df7d 100644 --- a/ImperatorToCK3/CK3/Cultures/Pillar.cs +++ b/ImperatorToCK3/CK3/Cultures/Pillar.cs @@ -1,25 +1,48 @@ using commonItems; using commonItems.Collections; -using ImperatorToCK3.Exceptions; +using commonItems.Colors; +using commonItems.Serialization; +using System.Collections.Generic; +using System.Text; namespace ImperatorToCK3.CK3.Cultures; -public class Pillar : IIdentifiable { +public class Pillar : IIdentifiable, IPDXSerializable { public string Id { get; } - public string Type { get; private set; } + public string Type { get; } + public Color? Color { get; } + private readonly List> attributes; + public IReadOnlyCollection> Attributes => attributes; - public Pillar(string id, BufferedReader pillarReader) { + public Pillar(string id, PillarData pillarData) { Id = id; - var parser = new Parser(); - parser.RegisterKeyword("type", reader => { - Type = reader.GetString(); - }); - parser.IgnoreUnregisteredItems(); - parser.ParseStream(pillarReader); + Type = pillarData.Type!; + Color = pillarData.Color; + attributes = new List>(pillarData.Attributes); + } + + public string Serialize(string indent, bool withBraces) { + var contentIndent = indent; + if (withBraces) { + contentIndent += '\t'; + } + + var sb = new StringBuilder(); + if (withBraces) { + sb.AppendLine("{"); + } - if (string.IsNullOrEmpty(Type)) { - throw new ConverterException($"Cultural pillar {id} has no type defined!"); + sb.Append(contentIndent).AppendLine($"type={Type}"); + if (Color is not null) { + sb.Append(contentIndent).AppendLine($"color={Color}"); } + sb.AppendLine(PDXSerializer.Serialize(Attributes, indent: contentIndent, withBraces: false)); + + if (withBraces) { + sb.Append(indent).Append('}'); + } + + return sb.ToString(); } } \ No newline at end of file diff --git a/ImperatorToCK3/CK3/Cultures/PillarCollection.cs b/ImperatorToCK3/CK3/Cultures/PillarCollection.cs index 15c273b02..538013bc9 100644 --- a/ImperatorToCK3/CK3/Cultures/PillarCollection.cs +++ b/ImperatorToCK3/CK3/Cultures/PillarCollection.cs @@ -1,6 +1,8 @@ using commonItems; using commonItems.Collections; +using commonItems.Colors; using commonItems.Mods; +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; @@ -10,12 +12,67 @@ namespace ImperatorToCK3.CK3.Cultures; public class PillarCollection : IdObjectCollection { public IEnumerable Heritages => this.Where(p => p.Type == "heritage").ToImmutableList(); + public PillarCollection(ColorFactory colorFactory) { + InitPillarDataParser(colorFactory); + } + public void LoadPillars(ModFilesystem ck3ModFS) { var parser = new Parser(); - parser.RegisterRegex(CommonRegexes.String, (reader, pillarId) => { - AddOrReplace(new Pillar(pillarId, reader)); - }); + parser.RegisterRegex(CommonRegexes.String, (reader, pillarId) => LoadPillar(pillarId, reader)); parser.IgnoreAndLogUnregisteredItems(); parser.ParseGameFolder("common/culture/pillars", ck3ModFS, "txt", true); } + + public void LoadConverterPillars(string converterCulturesPath){ + var parser = new Parser(); + parser.RegisterRegex(CommonRegexes.String, (reader, pillarId) => LoadPillar(pillarId, reader)); + parser.IgnoreAndLogUnregisteredItems(); + parser.ParseFolder(converterCulturesPath, "txt", true, logFilePaths: true); + } + + private void LoadPillar(string pillarId, BufferedReader pillarReader) { + pillarDataParser.ParseStream(pillarReader); + + if (pillarData.InvalidatingPillarIds.Any()) { + foreach (var existingPillar in this) { + if (!pillarData.InvalidatingPillarIds.Contains(existingPillar.Id)) { + continue; + } + Logger.Debug($"Pillar {pillarId} is invalidated by existing {existingPillar.Id}."); + return; + } + Logger.Debug($"Loading optional pillar {pillarId}..."); + } + if (pillarData.Type is null) { + Logger.Warn($"Pillar {pillarId} has no type defined! Skipping."); + return; + } + AddOrReplace(new Pillar(pillarId, pillarData)); + + // Reset pillar data for the next pillar. + pillarData = new PillarData(); + } + + private void InitPillarDataParser(ColorFactory colorFactory) { + pillarDataParser.RegisterKeyword("INVALIDATED_BY", reader => { + pillarData.InvalidatingPillarIds = reader.GetStrings(); + }); + pillarDataParser.RegisterKeyword("type", reader => { + pillarData.Type = reader.GetString(); + }); + pillarDataParser.RegisterKeyword("color", reader => { + try { + pillarData.Color = colorFactory.GetColor(reader); + } catch (Exception e) { + Logger.Warn($"Found invalid color when parsing pillar! {e.Message}"); + } + }); + pillarDataParser.RegisterRegex(CommonRegexes.String, (reader, keyword) => { + pillarData.Attributes.Add(new KeyValuePair(keyword, reader.GetStringOfItem())); + }); + pillarDataParser.IgnoreAndLogUnregisteredItems(); + } + + private PillarData pillarData = new(); + private readonly Parser pillarDataParser = new(); } \ No newline at end of file diff --git a/ImperatorToCK3/CK3/Cultures/PillarData.cs b/ImperatorToCK3/CK3/Cultures/PillarData.cs new file mode 100644 index 000000000..7b28cbafb --- /dev/null +++ b/ImperatorToCK3/CK3/Cultures/PillarData.cs @@ -0,0 +1,13 @@ +using commonItems; +using commonItems.Colors; +using System.Collections.Generic; + +namespace ImperatorToCK3.CK3.Cultures; + +public record PillarData { + public IEnumerable InvalidatingPillarIds { get; set; } = new List(); + public string? Type { get; set; } + public Color? Color { get; set; } + + public IList> Attributes { get; } = new List>(); +} \ No newline at end of file diff --git a/ImperatorToCK3/CK3/World.cs b/ImperatorToCK3/CK3/World.cs index af14faafb..064be1b89 100644 --- a/ImperatorToCK3/CK3/World.cs +++ b/ImperatorToCK3/CK3/World.cs @@ -45,6 +45,7 @@ public class World { public DynastyCollection Dynasties { get; } = new(); public ProvinceCollection Provinces { get; } = new(); public Title.LandedTitles LandedTitles { get; } = new(); + public PillarCollection CulturalPillars { get; } public CultureCollection Cultures { get; } public ReligionCollection Religions { get; } public IdObjectCollection MenAtArmsTypes { get; } = new(); @@ -104,9 +105,11 @@ public World(Imperator.World impWorld, Configuration config) { // Load CK3 cultures from CK3 mod filesystem. Logger.Info("Loading cultural pillars..."); - var culturalPillars = new PillarCollection(); - culturalPillars.LoadPillars(ModFS); - Cultures = new CultureCollection(ck3ColorFactory, culturalPillars); + CulturalPillars = new(ck3ColorFactory); + CulturalPillars.LoadPillars(ModFS); + Logger.Info("Loading converter cultural pillars..."); + CulturalPillars.LoadConverterPillars("configurables/cultural_pillars"); + Cultures = new CultureCollection(ck3ColorFactory, CulturalPillars); Logger.Info("Loading name lists..."); Cultures.LoadNameLists(ModFS); Logger.Info("Loading cultures..."); diff --git a/ImperatorToCK3/Data_Files/blankMod/output/common/culture/pillars/01_heritage.txt b/ImperatorToCK3/Data_Files/blankMod/output/common/culture/pillars/01_heritage.txt deleted file mode 100644 index b08afcc4a..000000000 --- a/ImperatorToCK3/Data_Files/blankMod/output/common/culture/pillars/01_heritage.txt +++ /dev/null @@ -1,3 +0,0 @@ -heritage_noheritage = { - type = heritage -} diff --git a/ImperatorToCK3/Data_Files/blankMod/output/common/culture/pillars/01_language.txt b/ImperatorToCK3/Data_Files/blankMod/output/common/culture/pillars/01_language.txt deleted file mode 100644 index d7327715e..000000000 --- a/ImperatorToCK3/Data_Files/blankMod/output/common/culture/pillars/01_language.txt +++ /dev/null @@ -1,17 +0,0 @@ -language_nolanguage = { - type = language - is_shown = { - language_is_shown_trigger = { - LANGUAGE = language_nolanguage - } - } - ai_will_do = { - value = 10 - if = { - limit = { has_cultural_pillar = language_nolanguage } - multiply = 10 - } - } - - color = { 0 0 0 } -} diff --git a/ImperatorToCK3/Data_Files/blankMod/output/common/culture/pillars/IRToCK3_heritage.txt b/ImperatorToCK3/Data_Files/blankMod/output/common/culture/pillars/IRToCK3_heritage.txt deleted file mode 100644 index 4e8a97859..000000000 --- a/ImperatorToCK3/Data_Files/blankMod/output/common/culture/pillars/IRToCK3_heritage.txt +++ /dev/null @@ -1,63 +0,0 @@ -heritage_aboriginal = { - type = heritage -} - -heritage_anatolian = { - type = heritage -} - -heritage_hittite = { - type = heritage -} - -heritage_arvanite = { - type = heritage -} - -heritage_chaldean = { - type = heritage -} - -heritage_gaulish = { - type = heritage -} - -heritage_punic = { - type = heritage -} - -heritage_romano_british = { - type = heritage -} - -heritage_romano_germanic = { - type = heritage -} - -heritage_east_germanic = { - type = heritage -} - -heritage_south_germanic = { - type = heritage -} - -heritage_thracian = { - type = heritage -} - -heritage_tyrrhenian = { - type = heritage -} - -heritage_tai = { - type = heritage -} - -heritage_palaungic = { - type = heritage -} - -heritage_caucasian = { - type = heritage -} diff --git a/ImperatorToCK3/Data_Files/blankMod/output/common/culture/pillars/00_heritage_venetic.txt b/ImperatorToCK3/Data_Files/configurables/cultural_pillars/00_heritage_venetic.txt similarity index 74% rename from ImperatorToCK3/Data_Files/blankMod/output/common/culture/pillars/00_heritage_venetic.txt rename to ImperatorToCK3/Data_Files/configurables/cultural_pillars/00_heritage_venetic.txt index 780c7b31a..833a69b86 100644 --- a/ImperatorToCK3/Data_Files/blankMod/output/common/culture/pillars/00_heritage_venetic.txt +++ b/ImperatorToCK3/Data_Files/configurables/cultural_pillars/00_heritage_venetic.txt @@ -1,5 +1,7 @@  heritage_venetic = { + INVALIDATED_BY = { heritage_venetic } + type = heritage parameters = { heritage_group_latin = yes diff --git a/ImperatorToCK3/Data_Files/blankMod/output/common/culture/pillars/00_language_venetic.txt b/ImperatorToCK3/Data_Files/configurables/cultural_pillars/00_language_venetic.txt similarity index 94% rename from ImperatorToCK3/Data_Files/blankMod/output/common/culture/pillars/00_language_venetic.txt rename to ImperatorToCK3/Data_Files/configurables/cultural_pillars/00_language_venetic.txt index 4df7c801e..4059221c7 100644 --- a/ImperatorToCK3/Data_Files/blankMod/output/common/culture/pillars/00_language_venetic.txt +++ b/ImperatorToCK3/Data_Files/configurables/cultural_pillars/00_language_venetic.txt @@ -1,5 +1,7 @@  language_venetic = { + INVALIDATED_BY = { language_venetic } + type = language is_shown = { language_is_shown_trigger = { diff --git a/ImperatorToCK3/Data_Files/configurables/cultural_pillars/IRToCK3_heritage.txt b/ImperatorToCK3/Data_Files/configurables/cultural_pillars/IRToCK3_heritage.txt new file mode 100644 index 000000000..33822aa97 --- /dev/null +++ b/ImperatorToCK3/Data_Files/configurables/cultural_pillars/IRToCK3_heritage.txt @@ -0,0 +1,79 @@ +heritage_aboriginal = { + INVALIDATED_BY = { heritage_aboriginal } + type = heritage +} + +heritage_anatolian = { + INVALIDATED_BY = { heritage_anatolian } + type = heritage +} + +heritage_hittite = { + INVALIDATED_BY = { heritage_hittite } + type = heritage +} + +heritage_arvanite = { + INVALIDATED_BY = { heritage_arvanite } + type = heritage +} + +heritage_chaldean = { + INVALIDATED_BY = { heritage_chaldean } + type = heritage +} + +heritage_gaulish = { + INVALIDATED_BY = { heritage_gaulish } + type = heritage +} + +heritage_punic = { + INVALIDATED_BY = { heritage_punic } + type = heritage +} + +heritage_romano_british = { + INVALIDATED_BY = { heritage_romano_british } + type = heritage +} + +heritage_romano_germanic = { + INVALIDATED_BY = { heritage_romano_germanic } + type = heritage +} + +heritage_east_germanic = { + INVALIDATED_BY = { heritage_east_germanic } + type = heritage +} + +heritage_south_germanic = { + INVALIDATED_BY = { heritage_south_germanic } + type = heritage +} + +heritage_thracian = { + INVALIDATED_BY = { heritage_thracian } + type = heritage +} + +heritage_tyrrhenian = { + INVALIDATED_BY = { heritage_tyrrhenian } + type = heritage +} + +heritage_tai = { + INVALIDATED_BY = { heritage_tai } + type = heritage +} + +heritage_palaungic = { + INVALIDATED_BY = { heritage_palaungic } + type = heritage +} + +heritage_caucasian = { + INVALIDATED_BY = { heritage_caucasian } + type = heritage +} diff --git a/ImperatorToCK3/Data_Files/blankMod/output/common/culture/pillars/IRToCK3_language.txt b/ImperatorToCK3/Data_Files/configurables/cultural_pillars/IRToCK3_language.txt similarity index 84% rename from ImperatorToCK3/Data_Files/blankMod/output/common/culture/pillars/IRToCK3_language.txt rename to ImperatorToCK3/Data_Files/configurables/cultural_pillars/IRToCK3_language.txt index ad469e945..c95a9fce7 100644 --- a/ImperatorToCK3/Data_Files/blankMod/output/common/culture/pillars/IRToCK3_language.txt +++ b/ImperatorToCK3/Data_Files/configurables/cultural_pillars/IRToCK3_language.txt @@ -1,4 +1,6 @@ language_gothic = { # https://en.wikipedia.org/wiki/East_Germanic_languages + INVALIDATED_BY = { language_gothic } + type = language is_shown = { language_is_shown_trigger = { @@ -15,11 +17,14 @@ color = gothic } + language_nuragic = { + INVALIDATED_BY = { language_nuragic } + type = language is_shown = { language_is_shown_trigger = { - LANGUAGE = language_nuragic + LANGUAGE = language_nuragic } } ai_will_do = { @@ -32,7 +37,10 @@ language_nuragic = { color = hsv { 0.2 0.25 0.5 } } + language_luwian = { + INVALIDATED_BY = { language_luwian } + type = language is_shown = { language_is_shown_trigger = { @@ -49,7 +57,10 @@ language_luwian = { color = hsv { 0.32 0.45 0.9 } } + language_lydian = { + INVALIDATED_BY = { language_lydian } + type = language is_shown = { language_is_shown_trigger = { @@ -66,7 +77,10 @@ language_lydian = { color = rgb { 149 101 186 } } + language_hittite = { + INVALIDATED_BY = { language_hittite } + type = language is_shown = { language_is_shown_trigger = { @@ -83,7 +97,10 @@ language_hittite = { color = hsv { 0.42 0.45 0.3 } } + language_phrygian = { + INVALIDATED_BY = { language_phrygian } + type = language is_shown = { language_is_shown_trigger = { @@ -100,7 +117,10 @@ language_phrygian = { color = rgb { 246 223 15 } } + language_albanian = { + INVALIDATED_BY = { language_albanian } + type = language is_shown = { language_is_shown_trigger = { @@ -117,7 +137,10 @@ language_albanian = { color = hsv { 0.4 0.01 0.02 } } + language_kemetic = { + INVALIDATED_BY = { language_kemetic } + type = language is_shown = { language_is_shown_trigger = { @@ -134,7 +157,10 @@ language_kemetic = { color = hsv { 0.15 1 0.7 } } + language_aramaic = { + INVALIDATED_BY = { language_aramaic } + type = language is_shown = { language_is_shown_trigger = { @@ -151,7 +177,10 @@ language_aramaic = { color = hsv { 0.05 1.0 0.5 } } + language_babylonian = { + INVALIDATED_BY = { language_babylonian } + type = language is_shown = { language_is_shown_trigger = { @@ -168,7 +197,10 @@ language_babylonian = { color = hsv { 0.7 0.15 0.77 } } + language_gaulish = { + INVALIDATED_BY = { language_gaulish } + type = language is_shown = { language_is_shown_trigger = { @@ -185,7 +217,10 @@ language_gaulish = { color = hsv { 0.3 0.7 0.4 } } + language_hebrew = { + INVALIDATED_BY = { language_hebrew } + type = language is_shown = { language_is_shown_trigger = { @@ -202,7 +237,10 @@ language_hebrew = { color = rgb { 99 193 217 } } + language_oscan = { + INVALIDATED_BY = { language_oscan } + type = language is_shown = { language_is_shown_trigger = { @@ -219,7 +257,10 @@ language_oscan = { color = { 117 131 50 } } + language_samnite = { + INVALIDATED_BY = { language_samnite } + type = language is_shown = { language_is_shown_trigger = { @@ -236,7 +277,10 @@ language_samnite = { color = { 117 131 150 } } + language_ligustic = { + INVALIDATED_BY = { language_ligustic } + type = language is_shown = { language_is_shown_trigger = { @@ -253,7 +297,10 @@ language_ligustic = { color = { 211 208 124 } } + language_messapic = { + INVALIDATED_BY = { language_messapic } + type = language is_shown = { language_is_shown_trigger = { @@ -270,7 +317,10 @@ language_messapic = { color = { 5 52 113 } } + language_sardonian = { + INVALIDATED_BY = { language_sardonian } + type = language is_shown = { language_is_shown_trigger = { @@ -287,7 +337,10 @@ language_sardonian = { color = { 29 16 31 } } + language_siculian = { + INVALIDATED_BY = { language_siculian } + type = language is_shown = { language_is_shown_trigger = { @@ -304,7 +357,10 @@ language_siculian = { color = { 226 216 174 } } + language_hunnic = { + INVALIDATED_BY = { language_hunnic } + type = language is_shown = { language_is_shown_trigger = { @@ -321,7 +377,10 @@ language_hunnic = { color = { 254 204 50 } } + language_punic = { + INVALIDATED_BY = { language_punic } + type = language is_shown = { language_is_shown_trigger = { @@ -338,7 +397,10 @@ language_punic = { color = { 74 174 85 } } + language_breathanach = { + INVALIDATED_BY = { language_breathanach } + type = language is_shown = { language_is_shown_trigger = { @@ -355,7 +417,10 @@ language_breathanach = { color = { 127 143 104 } } + language_laessin = { + INVALIDATED_BY = { language_laessin } + type = language is_shown = { language_is_shown_trigger = { @@ -372,7 +437,10 @@ language_laessin = { color = { 166 160 148 } } + language_thracian = { + INVALIDATED_BY = { language_thracian } + type = language is_shown = { language_is_shown_trigger = { @@ -389,7 +457,10 @@ language_thracian = { color = { 5 162 25 } } + language_dacian = { + INVALIDATED_BY = { language_dacian } + type = language is_shown = { language_is_shown_trigger = { @@ -406,7 +477,10 @@ language_dacian = { color = hsv { 0.0 0.5 1.0 } } + language_etruscan = { + INVALIDATED_BY = { language_etruscan } + type = language is_shown = { language_is_shown_trigger = { @@ -425,6 +499,8 @@ language_etruscan = { } language_elamite = { + INVALIDATED_BY = { language_elamite } + type = language is_shown = { language_is_shown_trigger = { @@ -443,6 +519,8 @@ language_elamite = { } language_tai = { + INVALIDATED_BY = { language_tai } + type = language is_shown = { language_is_shown_trigger = { @@ -461,6 +539,8 @@ language_tai = { } language_palaungic = { # from AsiaExtended mod https://steamcommunity.com/sharedfiles/filedetails/?id=2706635752 as of 2022-12-29 + INVALIDATED_BY = { language_palaungic } + type = language is_shown = { language_is_shown_trigger = { diff --git a/ImperatorToCK3/ImperatorToCK3.csproj b/ImperatorToCK3/ImperatorToCK3.csproj index 4ffc4e362..0d7649cb5 100644 --- a/ImperatorToCK3/ImperatorToCK3.csproj +++ b/ImperatorToCK3/ImperatorToCK3.csproj @@ -83,7 +83,7 @@ - + @@ -91,8 +91,8 @@ - - + + diff --git a/ImperatorToCK3/Outputter/PillarOutputter.cs b/ImperatorToCK3/Outputter/PillarOutputter.cs new file mode 100644 index 000000000..803e31ed1 --- /dev/null +++ b/ImperatorToCK3/Outputter/PillarOutputter.cs @@ -0,0 +1,19 @@ +using commonItems; +using commonItems.Serialization; +using ImperatorToCK3.CK3.Cultures; +using System.IO; + +namespace ImperatorToCK3.Outputter; + +public static class PillarOutputter { + public static void OutputPillars(string outputModName, PillarCollection pillars) { + Logger.Info("Outputting pillars..."); + var outputPath = Path.Combine("output", outputModName, "common/culture/pillars/IRtoCK3_all_pillars.txt"); + using var outputStream = File.OpenWrite(outputPath); + using var output = new StreamWriter(outputStream, System.Text.Encoding.UTF8); + + foreach (var pillar in pillars) { + output.WriteLine($"{pillar.Id}={PDXSerializer.Serialize(pillar)}"); + } + } +} \ No newline at end of file diff --git a/ImperatorToCK3/Outputter/WorldOutputter.cs b/ImperatorToCK3/Outputter/WorldOutputter.cs index 60659e783..29a84ca7a 100644 --- a/ImperatorToCK3/Outputter/WorldOutputter.cs +++ b/ImperatorToCK3/Outputter/WorldOutputter.cs @@ -38,6 +38,7 @@ public static void OutputWorld(World ck3World, Imperator.World imperatorWorld, C ); Logger.IncrementProgress(); + PillarOutputter.OutputPillars(outputName, ck3World.CulturalPillars); CulturesOutputter.OutputCultures(outputName, ck3World.Cultures); ReligionsOutputter.OutputHolySites(outputName, ck3World.Religions); @@ -120,6 +121,7 @@ private static void OutputModFile(string outputName) { modFileBuilder.AppendLine($"path = \"mod/{outputName}\""); modFileBuilder.AppendLine("replace_path=\"common/bookmarks\""); modFileBuilder.AppendLine("replace_path=\"common/culture/cultures\""); + modFileBuilder.AppendLine("replace_path=\"common/culture/pillars\""); modFileBuilder.AppendLine("replace_path=\"common/landed_titles\""); modFileBuilder.AppendLine("replace_path=\"common/religion/religions\""); modFileBuilder.AppendLine("replace_path=\"history/characters\""); @@ -158,6 +160,7 @@ private static void CreateFolders(string outputName) { SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "coat_of_arms", "coat_of_arms")); SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "culture")); SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "culture", "cultures")); + SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "culture", "pillars")); SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "dna_data")); SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "dynasties")); SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "landed_titles"));