From 45f20f24d656063055852acb77026ebe45b41b08 Mon Sep 17 00:00:00 2001 From: Seweryn Presnal Date: Tue, 7 Sep 2021 13:30:19 +0200 Subject: [PATCH] Configurable CK3 bookmark date (#305) #minor * Configurable CK3 bookmark date * Loc fixes * Remove unused variable in test --- .../CK3/Characters/CK3CharacterTests.cs | 4 ++- .../CK3/Dynasties/DynastyTests.cs | 4 ++- .../CK3/Provinces/ProvinceDetailsTests.cs | 7 ++-- .../CK3/Provinces/ProvinceMappingsTests.cs | 6 ++-- .../CK3/Provinces/ProvinceTests.cs | 2 +- .../CK3/Provinces/ProvincesTests.cs | 3 +- .../CK3/Titles/TitleHistoryTests.cs | 5 +-- .../CK3/Titles/TitleTests.cs | 2 +- ImperatorToCK3/CK3/Characters/Character.cs | 21 +++--------- ImperatorToCK3/CK3/Provinces/Province.cs | 4 +-- .../CK3/Provinces/ProvinceDetails.cs | 11 +++---- ImperatorToCK3/CK3/Provinces/Provinces.cs | 8 ++--- ImperatorToCK3/CK3/Titles/TitleHistory.cs | 11 +++---- ImperatorToCK3/CK3/Titles/TitlesHistory.cs | 8 ++--- ImperatorToCK3/CK3/World.cs | 25 +++++++++----- ImperatorToCK3/Configuration.cs | 24 ++++++++------ .../output/common/bookmarks/00_bookmarks.txt | 2 +- ...{bm_867_converted.dds => bm_converted.dds} | Bin ...{bm_867_converted.dds => bm_converted.dds} | Bin ...{bm_867_converted.dds => bm_converted.dds} | Bin .../english/CONVERTER_bookmarks_l_english.yml | 4 +-- .../french/CONVERTER_bookmarks_l_french.yml | 4 +-- .../german/CONVERTER_bookmarks_l_german.yml | 4 +-- .../korean/CONVERTER_bookmarks_l_korean.yml | 4 +-- .../russian/CONVERTER_bookmarks_l_russian.yml | 4 +-- .../CONVERTER_bookmarks_l_simp_chinese.yml | 4 +-- .../spanish/CONVERTER_bookmarks_l_spanish.yml | 4 +-- .../fronter_configuration/fronter-options.txt | 11 +++++++ .../options_l_english.yml | 10 ++++-- .../options_l_simp_chinese.yml | 2 +- ImperatorToCK3/Imperator/World.cs | 3 ++ .../Outputter/CharacterOutputter.cs | 6 ++-- .../Outputter/CharactersOutputter.cs | 5 +-- ImperatorToCK3/Outputter/TitlesOutputter.cs | 16 ++++----- ImperatorToCK3/Outputter/WorldOutputter.cs | 31 ++++++++++++++---- 35 files changed, 150 insertions(+), 109 deletions(-) rename ImperatorToCK3/Data_Files/blankMod/output/gfx/interface/bookmarks/{bm_867_converted.dds => bm_converted.dds} (100%) rename ImperatorToCK3/Data_Files/blankMod/output/gfx/interface/icons/bookmark_big/{bm_867_converted.dds => bm_converted.dds} (100%) rename ImperatorToCK3/Data_Files/blankMod/output/gfx/interface/icons/bookmark_buttons/{bm_867_converted.dds => bm_converted.dds} (100%) diff --git a/ImperatorToCK3.UnitTests/CK3/Characters/CK3CharacterTests.cs b/ImperatorToCK3.UnitTests/CK3/Characters/CK3CharacterTests.cs index 759021eb4..da5ebdd26 100644 --- a/ImperatorToCK3.UnitTests/CK3/Characters/CK3CharacterTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Characters/CK3CharacterTests.cs @@ -37,7 +37,9 @@ public Character Build() { localizationMapper, provinceMapper, deathReasonMapper, - convertBirthAndDeathDates + convertBirthAndDeathDates, + new Date(867, 1, 1), + new Date(867, 1, 1) ); return character; } diff --git a/ImperatorToCK3.UnitTests/CK3/Dynasties/DynastyTests.cs b/ImperatorToCK3.UnitTests/CK3/Dynasties/DynastyTests.cs index c7ac33604..fe1ef59bc 100644 --- a/ImperatorToCK3.UnitTests/CK3/Dynasties/DynastyTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Dynasties/DynastyTests.cs @@ -35,7 +35,9 @@ public Character Build() { localizationMapper, provinceMapper, deathReasonMapper, - convertBirthAndDeathDates + convertBirthAndDeathDates, + new Date(867, 1, 1), + new Date(867, 1, 1) ); return character; } diff --git a/ImperatorToCK3.UnitTests/CK3/Provinces/ProvinceDetailsTests.cs b/ImperatorToCK3.UnitTests/CK3/Provinces/ProvinceDetailsTests.cs index fe7f2c967..25f9837f3 100644 --- a/ImperatorToCK3.UnitTests/CK3/Provinces/ProvinceDetailsTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Provinces/ProvinceDetailsTests.cs @@ -6,6 +6,7 @@ namespace ImperatorToCK3.UnitTests.CK3.Provinces { [Collection("Sequential")] [CollectionDefinition("Sequential", DisableParallelization = true)] public class ProvinceDetailsTests { + private readonly Date ck3BookmarkDate = new(867, 1, 1); [Fact] public void FieldsDefaultToCorrectValues() { var details = new ProvinceDetails(); Assert.Equal(string.Empty, details.Culture); @@ -19,7 +20,7 @@ public void DetailsCanBeLoadedFromStream() { var reader = new BufferedReader( "= { religion = orthodox\n random_param = random_stuff\n culture = roman\n}" ); - var details = new ProvinceDetails(reader); + var details = new ProvinceDetails(reader, ck3BookmarkDate); Assert.Equal("roman", details.Culture); Assert.Equal("orthodox", details.Religion); @@ -35,7 +36,7 @@ public void DetailsAreLoadedFromDatedBlocks() { "850.1.1 = { religion=orthodox holding=castle_holding }" + "}" ); - var details = new ProvinceDetails(reader); + var details = new ProvinceDetails(reader, ck3BookmarkDate); Assert.Equal("castle_holding", details.Holding); Assert.Equal("orthodox", details.Religion); @@ -51,7 +52,7 @@ public void DetailsCanBeCopyConstructed() { "\t850.1.1 = { religion=orthodox holding=castle_holding }" + "}" ); - var details1 = new ProvinceDetails(reader); + var details1 = new ProvinceDetails(reader, ck3BookmarkDate); var details2 = new ProvinceDetails(details1); Assert.Equal("castle_holding", details2.Holding); diff --git a/ImperatorToCK3.UnitTests/CK3/Provinces/ProvinceMappingsTests.cs b/ImperatorToCK3.UnitTests/CK3/Provinces/ProvinceMappingsTests.cs index 182eebee0..92f446ae6 100644 --- a/ImperatorToCK3.UnitTests/CK3/Provinces/ProvinceMappingsTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Provinces/ProvinceMappingsTests.cs @@ -1,4 +1,5 @@ using ImperatorToCK3.CK3.Provinces; +using commonItems; using Xunit; namespace ImperatorToCK3.UnitTests.CK3.Provinces { @@ -14,11 +15,10 @@ public void MappingsDefaultToEmpty() { [Fact] public void MappingsCanBeLoadedFromFile() { var provinceMappings = new ProvinceMappings(testFilePath); - var province1 = new Province(id: 1, new commonItems.BufferedReader(string.Empty)); Assert.Collection(provinceMappings.Mappings, mapping1 => { Assert.Equal((ulong)3, mapping1.Key); Assert.Equal((ulong)1, mapping1.Value); }, - mapping1 => { Assert.Equal((ulong)4, mapping1.Key); Assert.Equal((ulong)1, mapping1.Value); }, - mapping1 => { Assert.Equal((ulong)5, mapping1.Key); Assert.Equal((ulong)4, mapping1.Value); } + mapping2 => { Assert.Equal((ulong)4, mapping2.Key); Assert.Equal((ulong)1, mapping2.Value); }, + mapping3 => { Assert.Equal((ulong)5, mapping3.Key); Assert.Equal((ulong)4, mapping3.Value); } ); } } diff --git a/ImperatorToCK3.UnitTests/CK3/Provinces/ProvinceTests.cs b/ImperatorToCK3.UnitTests/CK3/Provinces/ProvinceTests.cs index 80a45e31f..94e1d9e14 100644 --- a/ImperatorToCK3.UnitTests/CK3/Provinces/ProvinceTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Provinces/ProvinceTests.cs @@ -29,7 +29,7 @@ public void ProvinceCanBeLoadedFromStream() { var reader = new BufferedReader( "{ culture=roman random_key=random_value religion=orthodox holding=castle_holding }" ); - var province = new Province(42, reader); + var province = new Province(42, reader, new Date(867,1,1)); Assert.Equal((ulong)42, province.ID); Assert.Equal("orthodox", province.Religion); Assert.Equal("roman", province.Culture); diff --git a/ImperatorToCK3.UnitTests/CK3/Provinces/ProvincesTests.cs b/ImperatorToCK3.UnitTests/CK3/Provinces/ProvincesTests.cs index 11a600bb7..6fade2550 100644 --- a/ImperatorToCK3.UnitTests/CK3/Provinces/ProvincesTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Provinces/ProvincesTests.cs @@ -1,4 +1,5 @@ using Xunit; +using commonItems; namespace ImperatorToCK3.UnitTests.CK3.Provinces { [Collection("Sequential")] @@ -12,7 +13,7 @@ [Fact] public void ProvincesDefaltToEmpty() { [Fact] public void ProvincesAreProperlyLoadedFromFile() { - var provinces = new ImperatorToCK3.CK3.Provinces.Provinces("TestFiles/CK3ProvincesHistoryFile.txt"); + var provinces = new ImperatorToCK3.CK3.Provinces.Provinces("TestFiles/CK3ProvincesHistoryFile.txt", new Date(867,1,1)); Assert.Equal(4, provinces.StoredProvinces.Count); Assert.Equal("slovien", provinces.StoredProvinces[3080].Culture); diff --git a/ImperatorToCK3.UnitTests/CK3/Titles/TitleHistoryTests.cs b/ImperatorToCK3.UnitTests/CK3/Titles/TitleHistoryTests.cs index 852607d12..807add946 100644 --- a/ImperatorToCK3.UnitTests/CK3/Titles/TitleHistoryTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Titles/TitleHistoryTests.cs @@ -1,5 +1,6 @@ using ImperatorToCK3.CK3.Titles; using Xunit; +using commonItems; namespace ImperatorToCK3.UnitTests.CK3.Titles { public class TitleHistoryTests { @@ -33,7 +34,7 @@ public void DevelopmentLevelDefaultsToNull() { [Fact] public void HistoryCanBeLoadedFromStream() { - var titlesHistory = new TitlesHistory("TestFiles/title_history"); + var titlesHistory = new TitlesHistory("TestFiles/title_history", new Date(867,1,1)); var history = titlesHistory.PopTitleHistory("k_rome"); Assert.Equal("67", history.Holder); @@ -42,7 +43,7 @@ public void HistoryCanBeLoadedFromStream() { [Fact] public void HistoryIsLoadedFromDatedBlocks() { - var titlesHistory = new TitlesHistory("TestFiles/title_history"); + var titlesHistory = new TitlesHistory("TestFiles/title_history", new Date(867, 1, 1)); var history = titlesHistory.PopTitleHistory("k_greece"); Assert.Equal("420", history.Holder); diff --git a/ImperatorToCK3.UnitTests/CK3/Titles/TitleTests.cs b/ImperatorToCK3.UnitTests/CK3/Titles/TitleTests.cs index e5fff7ee3..bdf50e080 100644 --- a/ImperatorToCK3.UnitTests/CK3/Titles/TitleTests.cs +++ b/ImperatorToCK3.UnitTests/CK3/Titles/TitleTests.cs @@ -87,7 +87,7 @@ public void CapitalBaronyDefaultsToZero() { [Fact] public void HistoryCanBeAdded() { - var titlesHistory = new TitlesHistory("TestFiles/title_history"); + var titlesHistory = new TitlesHistory("TestFiles/title_history", new Date(867,1,1)); var history = titlesHistory.PopTitleHistory("k_greece"); var title = new Title(); title.AddHistory(new LandedTitles(), history); diff --git a/ImperatorToCK3/CK3/Characters/Character.cs b/ImperatorToCK3/CK3/Characters/Character.cs index 75529fba4..d463fbf3c 100644 --- a/ImperatorToCK3/CK3/Characters/Character.cs +++ b/ImperatorToCK3/CK3/Characters/Character.cs @@ -28,20 +28,6 @@ public class Character { public Imperator.Characters.Character? ImperatorCharacter { get; set; } - public void InitializeFromImperator( - Imperator.Characters.Character impCharacter, - ReligionMapper religionMapper, - CultureMapper cultureMapper, - TraitMapper traitMapper, - NicknameMapper nicknameMapper, - LocalizationMapper localizationMapper, - ProvinceMapper provinceMapper, // used to determine ck3 province for religion mapper - DeathReasonMapper deathReasonMapper, - bool ConvertBirthAndDeathDates = true - ) { - var dateOnConversion = new Date(867, 1, 1); - InitializeFromImperator(impCharacter, religionMapper, cultureMapper, traitMapper, nicknameMapper, localizationMapper, provinceMapper, deathReasonMapper, ConvertBirthAndDeathDates, dateOnConversion); - } public void InitializeFromImperator( Imperator.Characters.Character impCharacter, ReligionMapper religionMapper, @@ -52,7 +38,8 @@ public void InitializeFromImperator( ProvinceMapper provinceMapper, // used to determine ck3 province for religion mapper DeathReasonMapper deathReasonMapper, bool convertBirthAndDeathDates, - Date dateOnConversion + Date dateOnConversion, + Date ck3BookmarkDate ) { ImperatorCharacter = impCharacter; ImperatorCharacter.CK3Character = this; @@ -160,8 +147,8 @@ Date dateOnConversion DeathReason = deathReasonMapper.GetCK3ReasonForImperatorReason(impDeathReason); } if (!convertBirthAndDeathDates) { // if option to convert character age is chosen - BirthDate.AddYears((int)new Date(867, 1, 1).DiffInYears(dateOnConversion)); - DeathDate?.AddYears((int)new Date(867, 1, 1).DiffInYears(dateOnConversion)); + BirthDate.AddYears((int)ck3BookmarkDate.DiffInYears(dateOnConversion)); + DeathDate?.AddYears((int)ck3BookmarkDate.DiffInYears(dateOnConversion)); } } diff --git a/ImperatorToCK3/CK3/Provinces/Province.cs b/ImperatorToCK3/CK3/Provinces/Province.cs index aa236f98b..604f44988 100644 --- a/ImperatorToCK3/CK3/Provinces/Province.cs +++ b/ImperatorToCK3/CK3/Provinces/Province.cs @@ -6,10 +6,10 @@ namespace ImperatorToCK3.CK3.Provinces { public class Province { public Province() { } - public Province(ulong id, BufferedReader reader) { + public Province(ulong id, BufferedReader reader, Date ck3BookmarkDate) { // Load from a country file, if one exists. Otherwise rely on defaults. ID = id; - details = new ProvinceDetails(reader); + details = new ProvinceDetails(reader, ck3BookmarkDate); } public Province(ulong id, Province otherProvince) { ID = id; diff --git a/ImperatorToCK3/CK3/Provinces/ProvinceDetails.cs b/ImperatorToCK3/CK3/Provinces/ProvinceDetails.cs index a1996c642..1f3e52ed2 100644 --- a/ImperatorToCK3/CK3/Provinces/ProvinceDetails.cs +++ b/ImperatorToCK3/CK3/Provinces/ProvinceDetails.cs @@ -18,25 +18,24 @@ public ProvinceDetails(ProvinceDetails otherDetails) { Holding = otherDetails.Holding; Buildings = new List(otherDetails.Buildings); } - public ProvinceDetails(BufferedReader reader) { + public ProvinceDetails(BufferedReader reader, Date ck3BookmarkDate) { var history = historyFactory.GetHistory(reader); - var date = new Date(867, 1, 1); - var cultureOpt = history.GetSimpleFieldValue("culture", date); + var cultureOpt = history.GetSimpleFieldValue("culture", ck3BookmarkDate); if (cultureOpt is not null) { Culture = cultureOpt; } - var religionOpt = history.GetSimpleFieldValue("religion", date); + var religionOpt = history.GetSimpleFieldValue("religion", ck3BookmarkDate); if (religionOpt is not null) { Religion = religionOpt; } - var holdingOpt = history.GetSimpleFieldValue("holding", date); + var holdingOpt = history.GetSimpleFieldValue("holding", ck3BookmarkDate); if (holdingOpt is null) { Logger.Warn("Province's holding can't be null!"); } else { Holding = holdingOpt; } - var buildingsOpt = history.GetContainerFieldValue("buildings", date); + var buildingsOpt = history.GetContainerFieldValue("buildings", ck3BookmarkDate); if (buildingsOpt is null) { Logger.Warn("Province's buildings list can't be null!"); } else { diff --git a/ImperatorToCK3/CK3/Provinces/Provinces.cs b/ImperatorToCK3/CK3/Provinces/Provinces.cs index b643a5c2b..cd6d1c9b2 100644 --- a/ImperatorToCK3/CK3/Provinces/Provinces.cs +++ b/ImperatorToCK3/CK3/Provinces/Provinces.cs @@ -4,17 +4,17 @@ namespace ImperatorToCK3.CK3.Provinces { public class Provinces : Parser { public Provinces() { } - public Provinces(string filePath) { - RegisterKeys(); + public Provinces(string filePath, Date ck3BookmarkDate) { + RegisterKeys(ck3BookmarkDate); ParseFile(filePath); ClearRegisteredRules(); } public Dictionary StoredProvinces { get; } = new(); - private void RegisterKeys() { + private void RegisterKeys(Date ck3BookmarkDate) { RegisterRegex(CommonRegexes.Integer, (reader, provinceIdString) => { var provID = ulong.Parse(provinceIdString); - var newProvince = new Province(provID, reader); + var newProvince = new Province(provID, reader, ck3BookmarkDate); StoredProvinces.Add(provID, newProvince); }); RegisterRegex(CommonRegexes.Catchall, ParserHelpers.IgnoreAndLogItem); diff --git a/ImperatorToCK3/CK3/Titles/TitleHistory.cs b/ImperatorToCK3/CK3/Titles/TitleHistory.cs index 9a97f65e3..b9229d0b2 100644 --- a/ImperatorToCK3/CK3/Titles/TitleHistory.cs +++ b/ImperatorToCK3/CK3/Titles/TitleHistory.cs @@ -4,19 +4,18 @@ namespace ImperatorToCK3.CK3.Titles { public class TitleHistory { public TitleHistory() { } - public TitleHistory(History history) { + public TitleHistory(History history, Date ck3BookmarkDate) { this.history = history; - var date = new Date(867, 1, 1); - var holderFromHistory = history.GetSimpleFieldValue("holder", date); + var holderFromHistory = history.GetSimpleFieldValue("holder", ck3BookmarkDate); if (holderFromHistory is null) { Logger.Warn("TitleHistory: holder should not be null!"); } else { Holder = holderFromHistory; } - Liege = history.GetSimpleFieldValue("liege", date); - Government = history.GetSimpleFieldValue("government", date); + Liege = history.GetSimpleFieldValue("liege", ck3BookmarkDate); + Government = history.GetSimpleFieldValue("government", ck3BookmarkDate); - var developmentLevelOpt = history.GetSimpleFieldValue("development_level", date); + var developmentLevelOpt = history.GetSimpleFieldValue("development_level", ck3BookmarkDate); if (developmentLevelOpt is not null) { DevelopmentLevel = int.Parse(developmentLevelOpt); } diff --git a/ImperatorToCK3/CK3/Titles/TitlesHistory.cs b/ImperatorToCK3/CK3/Titles/TitlesHistory.cs index 19f43a3f6..a26de32a7 100644 --- a/ImperatorToCK3/CK3/Titles/TitlesHistory.cs +++ b/ImperatorToCK3/CK3/Titles/TitlesHistory.cs @@ -5,10 +5,10 @@ namespace ImperatorToCK3.CK3.Titles { public class TitlesHistory : Parser { public TitlesHistory() { } - public TitlesHistory(string folderPath) { + public TitlesHistory(string folderPath, Date ck3BookmarkDate) { var filenames = SystemUtils.GetAllFilesInFolderRecursive(folderPath); Logger.Info("Parsing title history."); - RegisterKeys(); + RegisterKeys(ck3BookmarkDate); foreach (var filename in filenames) { ParseFile(System.IO.Path.Combine(folderPath, filename)); } @@ -23,7 +23,7 @@ public TitlesHistory(string folderPath) { return null; } - private void RegisterKeys() { + private void RegisterKeys(Date ck3BookmarkDate) { RegisterRegex(@"(e|k|d|c|b)_[A-Za-z0-9_\-\']+", (reader, titleName) => { var historyItem = new StringOfItem(reader).String; if (historyItem.IndexOf('{') != -1) { @@ -32,7 +32,7 @@ private void RegisterKeys() { existingHistory.Update(historyFactory, tempReader); } else { var history = historyFactory.GetHistory(tempReader); - historyDict.Add(titleName, new TitleHistory(history)); + historyDict.Add(titleName, new TitleHistory(history, ck3BookmarkDate)); } } }); diff --git a/ImperatorToCK3/CK3/World.cs b/ImperatorToCK3/CK3/World.cs index e3f3a6fcf..2b1aceef5 100644 --- a/ImperatorToCK3/CK3/World.cs +++ b/ImperatorToCK3/CK3/World.cs @@ -43,7 +43,7 @@ public World(Imperator.World impWorld, Configuration theConfiguration) { // Load vanilla titles history var titlesHistoryPath = Path.Combine(theConfiguration.Ck3Path, "game/history/titles"); - titlesHistory = new TitlesHistory(titlesHistoryPath); + titlesHistory = new TitlesHistory(titlesHistoryPath, theConfiguration.Ck3BookmarkDate); // Loading vanilla CK3 landed titles var landedTitlesPath = Path.Combine(theConfiguration.Ck3Path, "game/common/landed_titles/00_landed_titles.txt"); @@ -61,12 +61,17 @@ public World(Imperator.World impWorld, Configuration theConfiguration) { // Now we can deal with provinces since we know to whom to assign them. We first import vanilla province data. // Some of it will be overwritten, but not all. - ImportVanillaProvinces(theConfiguration.Ck3Path); + ImportVanillaProvinces(theConfiguration.Ck3Path, theConfiguration.Ck3BookmarkDate); // Next we import Imperator provinces and translate them ontop a significant part of all imported provinces. ImportImperatorProvinces(impWorld); - ImportImperatorCharacters(impWorld, theConfiguration.ConvertBirthAndDeathDates, impWorld.EndDate); + ImportImperatorCharacters( + impWorld, + theConfiguration.ConvertBirthAndDeathDates, + impWorld.EndDate, + theConfiguration.Ck3BookmarkDate + ); LinkSpouses(); LinkMothersAndFathers(); @@ -77,11 +82,11 @@ public World(Imperator.World impWorld, Configuration theConfiguration) { PurgeLandlessVanillaCharacters(); } - private void ImportImperatorCharacters(Imperator.World impWorld, bool convertBirthAndDeathDates, Date endDate) { + private void ImportImperatorCharacters(Imperator.World impWorld, bool convertBirthAndDeathDates, Date endDate, Date ck3BookmarkDate) { Logger.Info("Importing Imperator Characters."); foreach (var character in impWorld.Characters.StoredCharacters.Values) { - ImportImperatorCharacter(character, convertBirthAndDeathDates, endDate); + ImportImperatorCharacter(character, convertBirthAndDeathDates, endDate, ck3BookmarkDate); } Logger.Info($"{Characters.Count} total characters recognized."); } @@ -89,7 +94,8 @@ private void ImportImperatorCharacters(Imperator.World impWorld, bool convertBir private void ImportImperatorCharacter( Imperator.Characters.Character character, bool convertBirthAndDeathDates, - Date endDate + Date endDate, + Date ck3BookmarkDate ) { // Create a new CK3 character var newCharacter = new Character(); @@ -102,7 +108,8 @@ Date endDate provinceMapper, deathReasonMapper, convertBirthAndDeathDates, - endDate + endDate, + ck3BookmarkDate ); character.CK3Character = newCharacter; Characters.Add(newCharacter.ID, newCharacter); @@ -148,7 +155,7 @@ Dictionary imperatorCountries } } - private void ImportVanillaProvinces(string ck3Path) { + private void ImportVanillaProvinces(string ck3Path, Date ck3BookmarkDate) { Logger.Info("Importing Vanilla Provinces."); // ---- Loading history/provinces var path = Path.Combine(ck3Path, "game/history/provinces"); @@ -158,7 +165,7 @@ private void ImportVanillaProvinces(string ck3Path) { continue; var provincesPath = Path.Combine(ck3Path, "game/history/provinces", fileName); try { - var newProvinces = new Provinces.Provinces(provincesPath); + var newProvinces = new Provinces.Provinces(provincesPath, ck3BookmarkDate); foreach (var (newProvinceID, newProvince) in newProvinces.StoredProvinces) { if (Provinces.ContainsKey(newProvinceID)) { Logger.Warn($"Vanilla province duplication - {newProvinceID} already loaded! Overwriting."); diff --git a/ImperatorToCK3/Configuration.cs b/ImperatorToCK3/Configuration.cs index 2646e638d..f4c94b64f 100644 --- a/ImperatorToCK3/Configuration.cs +++ b/ImperatorToCK3/Configuration.cs @@ -13,6 +13,7 @@ public class Configuration : Parser { public string OutputModName { get; internal set; } = ""; public IMPERATOR_DE_JURE ImperatorDeJure { get; internal set; } = IMPERATOR_DE_JURE.NO; public bool ConvertBirthAndDeathDates { get; internal set; } = true; + public Date Ck3BookmarkDate { get; private set; } = new(867, 1, 1); public Configuration(ConverterVersion converterVersion) { Logger.Info("Reading configuration file"); @@ -26,7 +27,7 @@ public Configuration(ConverterVersion converterVersion) { VerifyCK3Version(converterVersion); } - void RegisterKeys() { + private void RegisterKeys() { RegisterKeyword("SaveGame", (sr) => { SaveGamePath = new SingleString(sr).String; Logger.Info("Save game set to: " + SaveGamePath); @@ -58,13 +59,16 @@ void RegisterKeys() { }); RegisterKeyword("ConvertCharacterBirthAndDeathDates", (sr) => { var valStr = new SingleString(sr).String; - if (valStr == "true") { - ConvertBirthAndDeathDates = true; - } else { - ConvertBirthAndDeathDates = false; - } + ConvertBirthAndDeathDates = valStr == "true"; Logger.Info("Conversion of characters' birth and death dates set to: " + ConvertBirthAndDeathDates); }); + + RegisterKeyword("bookmark_date", reader => { + var dateStr = ParserHelpers.GetString(reader); + Logger.Info($"Entered CK3 bookmark date: {dateStr}"); + Ck3BookmarkDate = new Date(dateStr); + Logger.Info($"CK3 bookmark date set to: {Ck3BookmarkDate}"); + }); RegisterRegex(CommonRegexes.Catchall, ParserHelpers.IgnoreItem); } @@ -113,12 +117,12 @@ private void VerifyImperatorVersion(ConverterVersion converterVersion) { if (converterVersion.MinSource > ImpVersion) { Logger.Error($"Imperator version is v{ImpVersion.ToShortString()}," + $" converter requires minimum v{converterVersion.MinSource.ToShortString()}!"); - throw new ArgumentOutOfRangeException("Converter vs Imperator installation mismatch!"); + throw new ArgumentOutOfRangeException(nameof(ImpVersion), "Converter vs Imperator installation mismatch!"); } if (!converterVersion.MaxSource.IsLargerishThan(ImpVersion)) { Logger.Error($"Imperator version is v{ImpVersion.ToShortString()}, converter requires maximum v" + $"{converterVersion.MaxSource.ToShortString()}!"); - throw new ArgumentOutOfRangeException("Converter vs Imperator installation mismatch!"); + throw new ArgumentOutOfRangeException(nameof(ImpVersion), "Converter vs Imperator installation mismatch!"); } } @@ -135,12 +139,12 @@ private void VerifyCK3Version(ConverterVersion converterVersion) { if (converterVersion.MinTarget > CK3Version) { Logger.Error($"CK3 version is v{CK3Version.ToShortString()}, converter requires minimum v" + $"{converterVersion.MinTarget.ToShortString()}!"); - throw new ArgumentOutOfRangeException("Converter vs CK3 installation mismatch!"); + throw new ArgumentOutOfRangeException(nameof(CK3Version), "Converter vs CK3 installation mismatch!"); } if (!converterVersion.MaxTarget.IsLargerishThan(CK3Version)) { Logger.Error($"CK3 version is v{CK3Version.ToShortString()}, converter requires maximum v" + $"{converterVersion.MaxTarget.ToShortString()} !"); - throw new ArgumentOutOfRangeException("Converter vs CK3 installation mismatch!"); + throw new ArgumentOutOfRangeException(nameof(CK3Version), "Converter vs CK3 installation mismatch!"); } } } diff --git a/ImperatorToCK3/Data_Files/blankMod/output/common/bookmarks/00_bookmarks.txt b/ImperatorToCK3/Data_Files/blankMod/output/common/bookmarks/00_bookmarks.txt index 9a98a1280..2065b117f 100644 --- a/ImperatorToCK3/Data_Files/blankMod/output/common/bookmarks/00_bookmarks.txt +++ b/ImperatorToCK3/Data_Files/blankMod/output/common/bookmarks/00_bookmarks.txt @@ -1,4 +1,4 @@ -bm_867_converted = { +bm_converted = { start_date = 867.1.1 is_playable = yes recommended = yes diff --git a/ImperatorToCK3/Data_Files/blankMod/output/gfx/interface/bookmarks/bm_867_converted.dds b/ImperatorToCK3/Data_Files/blankMod/output/gfx/interface/bookmarks/bm_converted.dds similarity index 100% rename from ImperatorToCK3/Data_Files/blankMod/output/gfx/interface/bookmarks/bm_867_converted.dds rename to ImperatorToCK3/Data_Files/blankMod/output/gfx/interface/bookmarks/bm_converted.dds diff --git a/ImperatorToCK3/Data_Files/blankMod/output/gfx/interface/icons/bookmark_big/bm_867_converted.dds b/ImperatorToCK3/Data_Files/blankMod/output/gfx/interface/icons/bookmark_big/bm_converted.dds similarity index 100% rename from ImperatorToCK3/Data_Files/blankMod/output/gfx/interface/icons/bookmark_big/bm_867_converted.dds rename to ImperatorToCK3/Data_Files/blankMod/output/gfx/interface/icons/bookmark_big/bm_converted.dds diff --git a/ImperatorToCK3/Data_Files/blankMod/output/gfx/interface/icons/bookmark_buttons/bm_867_converted.dds b/ImperatorToCK3/Data_Files/blankMod/output/gfx/interface/icons/bookmark_buttons/bm_converted.dds similarity index 100% rename from ImperatorToCK3/Data_Files/blankMod/output/gfx/interface/icons/bookmark_buttons/bm_867_converted.dds rename to ImperatorToCK3/Data_Files/blankMod/output/gfx/interface/icons/bookmark_buttons/bm_converted.dds diff --git a/ImperatorToCK3/Data_Files/blankMod/output/localization/english/CONVERTER_bookmarks_l_english.yml b/ImperatorToCK3/Data_Files/blankMod/output/localization/english/CONVERTER_bookmarks_l_english.yml index a2a76ec29..fd42ae87f 100644 --- a/ImperatorToCK3/Data_Files/blankMod/output/localization/english/CONVERTER_bookmarks_l_english.yml +++ b/ImperatorToCK3/Data_Files/blankMod/output/localization/english/CONVERTER_bookmarks_l_english.yml @@ -1,3 +1,3 @@ l_english: - bm_867_converted:0 "A different world" - bm_867_converted_desc:1 "Centuries have passed, since the day Romulus first laid the stones of Rome and Ulysses devised the Wooden Horse. What has the world become until now? What will come next? Only the Gods know." + bm_converted:0 "A different world" + bm_converted_desc:1 "Centuries have passed, since the day Romulus first laid the stones of Rome and Ulysses devised the Wooden Horse. What has the world become until now? What will come next? Only the Gods know." diff --git a/ImperatorToCK3/Data_Files/blankMod/output/localization/french/CONVERTER_bookmarks_l_french.yml b/ImperatorToCK3/Data_Files/blankMod/output/localization/french/CONVERTER_bookmarks_l_french.yml index a00d620b3..33d61ee5e 100644 --- a/ImperatorToCK3/Data_Files/blankMod/output/localization/french/CONVERTER_bookmarks_l_french.yml +++ b/ImperatorToCK3/Data_Files/blankMod/output/localization/french/CONVERTER_bookmarks_l_french.yml @@ -1,3 +1,3 @@ l_french: - bm_867_converted:0 "Un monde différent" - bm_867_converted_desc:1 "Des siècles ont passé, depuis le jour où Romulus a posé les pierres de Rome et Ulysse a conçu le cheval de bois. Qu'est-ce que le monde est devenu jusqu'à présent? Qu'est-ce qu'il deviendra? Seuls les dieux le savent." \ No newline at end of file + bm_converted:0 "Un monde différent" + bm_converted_desc:1 "Des siècles ont passé, depuis le jour où Romulus a posé les pierres de Rome et Ulysse a conçu le cheval de bois. Qu'est-ce que le monde est devenu jusqu'à présent? Qu'est-ce qu'il deviendra? Seuls les dieux le savent." \ No newline at end of file diff --git a/ImperatorToCK3/Data_Files/blankMod/output/localization/german/CONVERTER_bookmarks_l_german.yml b/ImperatorToCK3/Data_Files/blankMod/output/localization/german/CONVERTER_bookmarks_l_german.yml index 87ef595b6..08a739f71 100644 --- a/ImperatorToCK3/Data_Files/blankMod/output/localization/german/CONVERTER_bookmarks_l_german.yml +++ b/ImperatorToCK3/Data_Files/blankMod/output/localization/german/CONVERTER_bookmarks_l_german.yml @@ -1,3 +1,3 @@ l_german: - bm_867_converted:0 "Eine andere Welt" - bm_867_converted_desc:1 "Jahrhunderte sind vergangen, seit Romulus die Steine Roms legte und Odysseus das Holzpferd entwarf. Was ist die Welt bis jetzt geworden? Wie wird sie? Nur die Götter wissen es." \ No newline at end of file + bm_converted:0 "Eine andere Welt" + bm_converted_desc:1 "Jahrhunderte sind vergangen, seit Romulus die Steine Roms legte und Odysseus das Holzpferd entwarf. Was ist die Welt bis jetzt geworden? Wie wird sie? Nur die Götter wissen es." \ No newline at end of file diff --git a/ImperatorToCK3/Data_Files/blankMod/output/localization/korean/CONVERTER_bookmarks_l_korean.yml b/ImperatorToCK3/Data_Files/blankMod/output/localization/korean/CONVERTER_bookmarks_l_korean.yml index 1a9b3283d..7b10df151 100644 --- a/ImperatorToCK3/Data_Files/blankMod/output/localization/korean/CONVERTER_bookmarks_l_korean.yml +++ b/ImperatorToCK3/Data_Files/blankMod/output/localization/korean/CONVERTER_bookmarks_l_korean.yml @@ -1,3 +1,3 @@ l_korean: - bm_867_converted:0 "또 다른 세계" - bm_867_converted_desc:1 "로물루스가 로마의 돌을 깔고 오디세우스가 목마를 디자인 한 지 수세기가 지났습니다. 지금까지 세상은 어떻게 되었습니까? 그녀는 어때? 신만이 알고 있습니다." \ No newline at end of file + bm_converted:0 "또 다른 세계" + bm_converted_desc:1 "로물루스가 로마의 돌을 깔고 오디세우스가 목마를 디자인 한 지 수세기가 지났습니다. 지금까지 세상은 어떻게 되었습니까? 그녀는 어때? 신만이 알고 있습니다." \ No newline at end of file diff --git a/ImperatorToCK3/Data_Files/blankMod/output/localization/russian/CONVERTER_bookmarks_l_russian.yml b/ImperatorToCK3/Data_Files/blankMod/output/localization/russian/CONVERTER_bookmarks_l_russian.yml index d7cb31a9d..78899c364 100644 --- a/ImperatorToCK3/Data_Files/blankMod/output/localization/russian/CONVERTER_bookmarks_l_russian.yml +++ b/ImperatorToCK3/Data_Files/blankMod/output/localization/russian/CONVERTER_bookmarks_l_russian.yml @@ -1,3 +1,3 @@ l_russian: - bm_867_converted:0 "Другой мир" - bm_867_converted_desc:1 "Прошли столетия с того дня, как Ромул впервые заложил камни Рима, а Улисс изобрел деревянного коня. Во что превратился мир до сих пор? Что будет? Только боги знают." \ No newline at end of file + bm_converted:0 "Другой мир" + bm_converted_desc:1 "Прошли столетия с того дня, как Ромул впервые заложил камни Рима, а Улисс изобрел деревянного коня. Во что превратился мир до сих пор? Что будет? Только боги знают." \ No newline at end of file diff --git a/ImperatorToCK3/Data_Files/blankMod/output/localization/simp_chinese/CONVERTER_bookmarks_l_simp_chinese.yml b/ImperatorToCK3/Data_Files/blankMod/output/localization/simp_chinese/CONVERTER_bookmarks_l_simp_chinese.yml index 3e6ff9da1..205ba00f7 100644 --- a/ImperatorToCK3/Data_Files/blankMod/output/localization/simp_chinese/CONVERTER_bookmarks_l_simp_chinese.yml +++ b/ImperatorToCK3/Data_Files/blankMod/output/localization/simp_chinese/CONVERTER_bookmarks_l_simp_chinese.yml @@ -1,3 +1,3 @@ l_simp_chinese: - bm_867_converted:0 "一个不同的世界" - bm_867_converted_desc:1 "自从罗慕路斯第一次奠定罗马的石头之日起,几个世纪过去了,尤利西斯设计了木马。 到现在为止世界已经变成了什么? 接下来会发生什么? 只有神知道。" + bm_converted:0 "一个不同的世界" + bm_converted_desc:1 "自从罗慕路斯第一次奠定罗马的石头之日起,几个世纪过去了,尤利西斯设计了木马。 到现在为止世界已经变成了什么? 接下来会发生什么? 只有神知道。" diff --git a/ImperatorToCK3/Data_Files/blankMod/output/localization/spanish/CONVERTER_bookmarks_l_spanish.yml b/ImperatorToCK3/Data_Files/blankMod/output/localization/spanish/CONVERTER_bookmarks_l_spanish.yml index 1033456a0..1403d0cbf 100644 --- a/ImperatorToCK3/Data_Files/blankMod/output/localization/spanish/CONVERTER_bookmarks_l_spanish.yml +++ b/ImperatorToCK3/Data_Files/blankMod/output/localization/spanish/CONVERTER_bookmarks_l_spanish.yml @@ -1,3 +1,3 @@ l_spanish: - bm_867_converted:0 "Un mundo diferente" - bm_867_converted_desc:1 "Han pasado siglos desde el día en que Rómulo colocó las piedras de Roma y Ulises diseñó el caballo de madera. ¿En qué se ha convertido el mundo hasta ahora? ¿Qué será de él? Solo los dioses lo saben." \ No newline at end of file + bm_converted:0 "Un mundo diferente" + bm_converted_desc:1 "Han pasado siglos desde el día en que Rómulo colocó las piedras de Roma y Ulises diseñó el caballo de madera. ¿En qué se ha convertido el mundo hasta ahora? ¿Qué será de él? Solo los dioses lo saben." \ No newline at end of file diff --git a/ImperatorToCK3/Data_Files/fronter_configuration/fronter-options.txt b/ImperatorToCK3/Data_Files/fronter_configuration/fronter-options.txt index 0ff1f8025..8e7746cc0 100644 --- a/ImperatorToCK3/Data_Files/fronter_configuration/fronter-options.txt +++ b/ImperatorToCK3/Data_Files/fronter_configuration/fronter-options.txt @@ -52,3 +52,14 @@ option = { tooltip = MODNAMETIP2 } } + +option = { + name = bookmark_date + displayName = BOOKMARKDATE + tooltip = BOOKMARKDATETIP + textSelector = { + value = "867.1.1" + editable = true + tooltip = BOOKMARKDATETIP2 + } +} diff --git a/ImperatorToCK3/Data_Files/fronter_configuration/options_l_english.yml b/ImperatorToCK3/Data_Files/fronter_configuration/options_l_english.yml index 8b4d90ce1..d9678b7f6 100644 --- a/ImperatorToCK3/Data_Files/fronter_configuration/options_l_english.yml +++ b/ImperatorToCK3/Data_Files/fronter_configuration/options_l_english.yml @@ -13,8 +13,12 @@ l_english: CONVERTCHARACTERBIRTHANDDEATHDATES_1: "Birth date" CONVERTCHARACTERBIRTHANDDEATHDATES_1_TIP: "Recommended when you're converting without a big time gap." CONVERTCHARACTERBIRTHANDDEATHDATES_2: "Age" - CONVERTCHARACTERBIRTHANDDEATHDATES_2_TIP: "Recommended when you're converting much earlier than 867 AD." + CONVERTCHARACTERBIRTHANDDEATHDATES_2_TIP: "Recommended when you're converting much earlier than the CK3 bookmark date." MODNAME: "Mod Output Name (optional):" - MODNAMETIP: "Please, stick to Latin letters" - MODNAMETIP2: "Optional name for the converted mod (default name is the one of the savegame)" \ No newline at end of file + MODNAMETIP: "Please, stick to Latin letters." + MODNAMETIP2: "Optional name for the converted mod (default name is the one of the savegame)." + + BOOKMARKDATE: "CK3 bookmark date (AD)" + BOOKMARKDATETIP: "Anno Domini date of the generated CK3 bookmark, can not be earlier than the Anno Domini Imperator save date" + BOOKMARKDATETIP2: "year.month.day format" \ No newline at end of file diff --git a/ImperatorToCK3/Data_Files/fronter_configuration/options_l_simp_chinese.yml b/ImperatorToCK3/Data_Files/fronter_configuration/options_l_simp_chinese.yml index fc73b9f92..19c131b6a 100644 --- a/ImperatorToCK3/Data_Files/fronter_configuration/options_l_simp_chinese.yml +++ b/ImperatorToCK3/Data_Files/fronter_configuration/options_l_simp_chinese.yml @@ -13,7 +13,7 @@ l_simp_chinese: CONVERTCHARACTERBIRTHANDDEATHDATES_1: "基于出生日期" CONVERTCHARACTERBIRTHANDDEATHDATES_1_TIP: "建议在你并无巨大时间差转换时使用。" CONVERTCHARACTERBIRTHANDDEATHDATES_2: "年龄" - CONVERTCHARACTERBIRTHANDDEATHDATES_2_TIP: "推荐当你从远早于AD867年的存档转换时使用。" + CONVERTCHARACTERBIRTHANDDEATHDATES_2_TIP: "推荐当你从远早于AD867年的存档转换时使用。" #outdated, CK3 bookmark date isn't always 867 now MODNAME: "MOD导出名称(可选):" MODNAMETIP: "请使用Latin字母" diff --git a/ImperatorToCK3/Imperator/World.cs b/ImperatorToCK3/Imperator/World.cs index 8803ee4c8..e94ef59fe 100644 --- a/ImperatorToCK3/Imperator/World.cs +++ b/ImperatorToCK3/Imperator/World.cs @@ -53,6 +53,9 @@ public World(Configuration configuration, ConverterVersion converterVersion) { var dateString = new SingleString(reader).String; EndDate = new Date(dateString, AUC: true); // converted to AD Logger.Info("Date: " + dateString); + if (EndDate > configuration.Ck3BookmarkDate) { + Logger.Error("Save date is later than CK3 bookmark date, proceeding at your own risk!"); + } }); RegisterKeyword("enabled_dlcs", reader => { var theDLCs = new StringList(reader).Strings; diff --git a/ImperatorToCK3/Outputter/CharacterOutputter.cs b/ImperatorToCK3/Outputter/CharacterOutputter.cs index b5789e51b..a0a76be6d 100644 --- a/ImperatorToCK3/Outputter/CharacterOutputter.cs +++ b/ImperatorToCK3/Outputter/CharacterOutputter.cs @@ -4,7 +4,7 @@ namespace ImperatorToCK3.Outputter { public static class CharacterOutputter { - public static void OutputCharacter(StreamWriter output, Character character) { + public static void OutputCharacter(StreamWriter output, Character character, Date ck3BookmarkDate) { // output ID, name, sex, culture, religion output.WriteLine($"{character.ID} = {{"); if (!string.IsNullOrEmpty(character.Name)) { @@ -34,12 +34,12 @@ public static void OutputCharacter(StreamWriter output, Character character) { // output spouse // TODO: output add_spouse with earlier date if the pair has a born or unborn child foreach (var spouseID in character.Spouses.Keys) { - output.WriteLine($"\t867.1.1 = {{ add_spouse = {spouseID} }}"); + output.WriteLine($"\t{ck3BookmarkDate} = {{ add_spouse = {spouseID} }}"); } // output nickname if (character.Nickname is not null) { - var nicknameDate = new Date(867, 1, 1); + var nicknameDate = ck3BookmarkDate; if (character.DeathDate is not null) { nicknameDate = character.DeathDate; } diff --git a/ImperatorToCK3/Outputter/CharactersOutputter.cs b/ImperatorToCK3/Outputter/CharactersOutputter.cs index 7e18d9391..efde93e1e 100644 --- a/ImperatorToCK3/Outputter/CharactersOutputter.cs +++ b/ImperatorToCK3/Outputter/CharactersOutputter.cs @@ -1,16 +1,17 @@ using System.Collections.Generic; using System.IO; using ImperatorToCK3.CK3.Characters; +using commonItems; namespace ImperatorToCK3.Outputter { public static class CharactersOutputter { - public static void OutputCharacters(string outputModName, Dictionary characters) { + public static void OutputCharacters(string outputModName, Dictionary characters, Date ck3BookmarkDate) { // dumping all into one file var path = "output/" + outputModName + "/history/characters/fromImperator.txt"; using var stream = File.OpenWrite(path); using var output = new StreamWriter(stream, System.Text.Encoding.UTF8); foreach (var character in characters.Values) { - CharacterOutputter.OutputCharacter(output, character); + CharacterOutputter.OutputCharacter(output, character, ck3BookmarkDate); } } } diff --git a/ImperatorToCK3/Outputter/TitlesOutputter.cs b/ImperatorToCK3/Outputter/TitlesOutputter.cs index c477a40d1..5b6f43e7e 100644 --- a/ImperatorToCK3/Outputter/TitlesOutputter.cs +++ b/ImperatorToCK3/Outputter/TitlesOutputter.cs @@ -6,10 +6,10 @@ namespace ImperatorToCK3.Outputter { public static class TitlesOutputter { - public static void OutputTitleHistory(Title title, StreamWriter writer) { + public static void OutputTitleHistory(Title title, StreamWriter writer, Date ck3BookmarkDate) { writer.WriteLine(title.Name + " = {"); - writer.WriteLine("\t867.1.1 = {"); + writer.WriteLine($"\t{ck3BookmarkDate} = {{"); var deFactoLiege = title.DeFactoLiege; if (deFactoLiege is not null) { @@ -43,19 +43,19 @@ public static void OutputTitleHistory(Title title, StreamWriter writer) { writer.WriteLine("}"); } - public static void OutputTitlesHistory(string outputModName, Dictionary titles) { + public static void OutputTitlesHistory(string outputModName, Dictionary titles, Date ck3BookmarkDate) { //output title history var alreadyOutputtedTitles = new HashSet(); foreach (var (name, title) in titles) { // first output kindoms + their de jure vassals to files named after the kingdoms if (title.Rank == TitleRank.kingdom && title.DeJureVassals.Count > 0) { // is a de jure kingdom var historyOutputPath = Path.Combine("output", outputModName, "history", "titles", name + ".txt"); using var historyOutput = new StreamWriter(historyOutputPath); // output the kingdom's history - OutputTitleHistory(title, historyOutput); + OutputTitleHistory(title, historyOutput, ck3BookmarkDate); alreadyOutputtedTitles.Add(name); // output the kingdom's de jure vassals' history foreach (var (deJureVassalName, deJureVassal) in title.GetDeJureVassalsAndBelow()) { - OutputTitleHistory(deJureVassal, historyOutput); + OutputTitleHistory(deJureVassal, historyOutput, ck3BookmarkDate); alreadyOutputtedTitles.Add(deJureVassalName); } } @@ -65,14 +65,14 @@ public static void OutputTitlesHistory(string outputModName, Dictionary titles, IMPERATOR_DE_JURE deJure) { + public static void OutputTitles(string outputModName, string ck3Path, Dictionary titles, IMPERATOR_DE_JURE deJure, Date ck3BookmarkDate) { //output to landed_titles folder foreach (var (name, title) in titles) { var impCountry = title.ImperatorCountry; @@ -93,7 +93,7 @@ public static void OutputTitles(string outputModName, string ck3Path, Dictionary } } - OutputTitlesHistory(outputModName, titles); + OutputTitlesHistory(outputModName, titles, ck3BookmarkDate); } } } diff --git a/ImperatorToCK3/Outputter/WorldOutputter.cs b/ImperatorToCK3/Outputter/WorldOutputter.cs index 26eefdc50..6b97a7c83 100644 --- a/ImperatorToCK3/Outputter/WorldOutputter.cs +++ b/ImperatorToCK3/Outputter/WorldOutputter.cs @@ -25,7 +25,7 @@ public static void OutputWorld(World ck3World, Configuration theConfiguration) { CreateFolders(outputName); Logger.Info("Writing Characters."); - CharactersOutputter.OutputCharacters(outputName, ck3World.Characters); + CharactersOutputter.OutputCharacters(outputName, ck3World.Characters, theConfiguration.Ck3BookmarkDate); Logger.Info("Writing Dynasties."); DynastiesOutputter.OutputDynasties(outputName, ck3World.Dynasties); @@ -34,23 +34,42 @@ public static void OutputWorld(World ck3World, Configuration theConfiguration) { ProvincesOutputter.OutputProvinces(outputName, ck3World.Provinces, ck3World.LandedTitles); Logger.Info("Writing Landed Titles."); - TitlesOutputter.OutputTitles(outputName, theConfiguration.Ck3Path, ck3World.LandedTitles, theConfiguration.ImperatorDeJure); + TitlesOutputter.OutputTitles( + outputName, + theConfiguration.Ck3Path, + ck3World.LandedTitles, + theConfiguration.ImperatorDeJure, + theConfiguration.Ck3BookmarkDate + ); Logger.Info("Writing Localization."); - LocalizationOutputter.OutputLocalization(theConfiguration.ImperatorPath, outputName, ck3World, theConfiguration.ImperatorDeJure); + LocalizationOutputter.OutputLocalization( + theConfiguration.ImperatorPath, + outputName, + ck3World, + theConfiguration.ImperatorDeJure + ); + + var outputPath = "output/" + theConfiguration.OutputModName; Logger.Info("Copying named colors."); SystemUtils.TryCopyFile(theConfiguration.ImperatorPath + "/game/common/named_colors/default_colors.txt", - "output/" + theConfiguration.OutputModName + "/common/named_colors/imp_colors.txt"); + outputPath + "/common/named_colors/imp_colors.txt"); Logger.Info("Copying Coats of Arms."); ColoredEmblemsOutputter.CopyColoredEmblems(theConfiguration, outputName); CoatOfArmsOutputter.OutputCoas(outputName, ck3World.LandedTitles); SystemUtils.TryCopyFolder(theConfiguration.ImperatorPath + "/game/gfx/coat_of_arms/patterns", - "output/" + theConfiguration.OutputModName + "/gfx/coat_of_arms/patterns"); + outputPath + "/gfx/coat_of_arms/patterns"); Logger.Info("Copying blankMod files to output."); - SystemUtils.TryCopyFolder("blankMod/output", "output/" + theConfiguration.OutputModName); + SystemUtils.TryCopyFolder("blankMod/output", outputPath); + + Logger.Info("Setting bookmark date."); + var bookmarkPath = Path.Combine(outputPath, "common/bookmarks/00_bookmarks.txt"); + string text = File.ReadAllText(bookmarkPath); + text = text.Replace("867.1.1", theConfiguration.Ck3BookmarkDate.ToString()); + File.WriteAllText(bookmarkPath, text); } private static void OutputModFile(string outputName) {