From 17c37097d1db1082537cc52aaa8728572079f5e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivo=20Elezovi=C4=87?= Date: Sun, 25 Feb 2024 14:46:58 +0100 Subject: [PATCH] Fix+config for wonky dynastic names. (#528) --- .clang-format | 1 - CK3ToEU4/Data_Files/fronter-options.txt | 19 ++++++++++++++ CK3ToEU4/Data_Files/options_l_english.yml | 6 +++++ CK3ToEU4/Data_Files/options_l_french.yml | 6 +++++ CK3ToEU4/Data_Files/options_l_german.yml | 6 +++++ CK3ToEU4/Data_Files/options_l_italian.yml | 6 +++++ CK3ToEU4/Data_Files/options_l_latin.yml | 6 +++++ CK3ToEU4/Data_Files/options_l_russian.yml | 6 +++++ .../Source/Configuration/Configuration.cpp | 5 ++++ CK3ToEU4/Source/Configuration/Configuration.h | 7 ++++++ CK3ToEU4/Source/EU4World/Country/Country.cpp | 23 ++++++++++------- CK3ToEU4/Source/EU4World/Country/Country.h | 5 ++-- CK3ToEU4/Source/EU4World/EU4World.cpp | 25 +++++++++++-------- CK3ToEU4/Source/EU4World/EU4World.h | 5 ++-- commonItems | 2 +- 15 files changed, 103 insertions(+), 25 deletions(-) diff --git a/.clang-format b/.clang-format index e82e7cbe..47c51026 100644 --- a/.clang-format +++ b/.clang-format @@ -24,7 +24,6 @@ ColumnLimit: 160 Cpp11BracedListStyle: true IndentCaseLabels: true IndentWidth: 3 -SortIncludes: false DerivePointerAlignment: false MaxEmptyLinesToKeep: 3 PointerAlignment: Left diff --git a/CK3ToEU4/Data_Files/fronter-options.txt b/CK3ToEU4/Data_Files/fronter-options.txt index 720a7cd9..d7a33f47 100644 --- a/CK3ToEU4/Data_Files/fronter-options.txt +++ b/CK3ToEU4/Data_Files/fronter-options.txt @@ -260,6 +260,25 @@ option = { #Historic (eurocentric) vs. Dynamic Insitutions/idea selection } } } +option = { #Dynastic names + name = dynasticNames + displayName = DYNASTICNAMES + tooltip = DYNASTICNAMESTIP + radioSelector = { + radioOption = { + name = 1 + displayName = DYNASTICNAMES1 + tooltip = DYNASTICNAMES1TIP + default = true + } + radioOption = { + name = 2 + displayName = DYNASTICNAMES2 + tooltip = DYNASTICNAMES2TIP + default = false + } + } +} option = { name = output_name displayName = MODNAME diff --git a/CK3ToEU4/Data_Files/options_l_english.yml b/CK3ToEU4/Data_Files/options_l_english.yml index d5877847..ad64e97b 100644 --- a/CK3ToEU4/Data_Files/options_l_english.yml +++ b/CK3ToEU4/Data_Files/options_l_english.yml @@ -75,6 +75,12 @@ l_english: INSTITUTIONS1TIP: "Use the basegame institution spawn and idea selection." INSTITUTIONS2: "Dynamic" INSTITUTIONS2TIP: "Use dynamic institution spawn and idea selection." + DYNASTICNAMES: "Do we use dynastic names when available?" + DYNASTICNAMESTIP: "Mainly for Islamic nations that use dynasty name in title." + DYNASTICNAMES1: "Yes, I want Ottomans." + DYNASTICNAMES1TIP: "Use when possible and appropriate." + DYNASTICNAMES2: "No, I want Türkiye." + DYNASTICNAMES2TIP: "Disabled." 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)" diff --git a/CK3ToEU4/Data_Files/options_l_french.yml b/CK3ToEU4/Data_Files/options_l_french.yml index 8952b8aa..7043c630 100644 --- a/CK3ToEU4/Data_Files/options_l_french.yml +++ b/CK3ToEU4/Data_Files/options_l_french.yml @@ -75,6 +75,12 @@ l_french: INSTITUTIONS1TIP: "On suive les règles du jeu vanille." INSTITUTIONS2: "Dynamique" INSTITUTIONS2TIP: "On crée des règles dynamiques." + DYNASTICNAMES: "Utilisons-nous des noms dynastiques lorsqu’ils sont disponibles ?" + DYNASTICNAMESTIP: "Principalement pour les nations islamiques qui utilisent le nom de la dynastie dans leur titre." + DYNASTICNAMES1: "Oui, je veux des Ottomans." + DYNASTICNAMES1TIP: "Utiliser lorsque cela est possible et approprié." + DYNASTICNAMES2: "Non, je veux Türkiye." + DYNASTICNAMES2TIP: "Désactivé." MODNAME: "Nom de sortie du mod (facultatif):" MODNAMETIP: "Veuillez vous en tenir aux lettres latines" MODNAMETIP2: "Nom facultatif pour le mod converti (le nom par défaut est celui de la sauvegarde)" diff --git a/CK3ToEU4/Data_Files/options_l_german.yml b/CK3ToEU4/Data_Files/options_l_german.yml index ad3eb9ce..680fa506 100644 --- a/CK3ToEU4/Data_Files/options_l_german.yml +++ b/CK3ToEU4/Data_Files/options_l_german.yml @@ -75,6 +75,12 @@ l_german: INSTITUTIONS1TIP: "Verwenden Sie die Vanillaspiel Regelen für Institutionen und Idee selektion." INSTITUTIONS2: "Dynamisch" INSTITUTIONS2TIP: "Verwenden Sie neue dynamische Regeln." + DYNASTICNAMES: "Verwenden wir dynastische Namen, sofern verfügbar?" + DYNASTICNAMESTIP: "Hauptsächlich für islamische Nationen, die den Namen einer Dynastie im Titel verwenden." + DYNASTICNAMES1: "Ja, ich möchte Osmanen." + DYNASTICNAMES1TIP: "Verwenden Sie es, wenn möglich und angemessen." + DYNASTICNAMES2: "Nein, ich will Türkiye." + DYNASTICNAMES2TIP: "Deaktiviert." MODNAME: "Mod Output Name (optional):" MODNAMETIP: "Bitte halten Sie sich an lateinische Buchstaben" MODNAMETIP2: "Optionaler Name für den konvertierten Mod (Standardname ist derselbe des Savegames)" diff --git a/CK3ToEU4/Data_Files/options_l_italian.yml b/CK3ToEU4/Data_Files/options_l_italian.yml index 69bb2205..7498dab4 100644 --- a/CK3ToEU4/Data_Files/options_l_italian.yml +++ b/CK3ToEU4/Data_Files/options_l_italian.yml @@ -75,6 +75,12 @@ l_italian: INSTITUTIONS1TIP: "Seguiamo le regole del vanilla." INSTITUTIONS2: "Dinamico" INSTITUTIONS2TIP: "Creiamo regole dinamiche." + DYNASTICNAMES: "Usiamo nomi dinastici quando disponibili?" + DYNASTICNAMESTIP: "Principalmente per le nazioni islamiche che utilizzano il nome della dinastia nel titolo." + DYNASTICNAMES1: "Sì, voglio gli ottomani." + DYNASTICNAMES1TIP: "Utilizzare quando possibile e appropriato." + DYNASTICNAMES2: "No, voglio Türkiye." + DYNASTICNAMES2TIP: "Disabilitato." MODNAME: "Nome della mod (opzionale):" MODNAMETIP: "Per favore, usa solo lettere latine" MODNAMETIP2: "Nome facoltativo per la mod convertita (il nome predefinito è quello del salvataggio)" diff --git a/CK3ToEU4/Data_Files/options_l_latin.yml b/CK3ToEU4/Data_Files/options_l_latin.yml index d295abae..1de75018 100644 --- a/CK3ToEU4/Data_Files/options_l_latin.yml +++ b/CK3ToEU4/Data_Files/options_l_latin.yml @@ -75,6 +75,12 @@ l_latin: INSTITUTIONS1TIP: "Utere basegame lectio instituta pariunt sententiam." INSTITUTIONS2: "Dynamic" INSTITUTIONS2TIP: "Delectu usus admodum instituit pariunt sententiam." + DYNASTICNAMES: "Utimur dynasticis nominibus, cum praesto?" + DYNASTICNAMESTIP: "Maxime pro islamicis gentibus quae nomine dynastia in titulo utuntur." + DYNASTICNAMES1: "Ottomanos ita volo." + DYNASTICNAMES1TIP: "Utere, cum fieri potest et oportet." + DYNASTICNAMES2: "Non, Türkiye volo." + DYNASTICNAMES2TIP: "Debilis." MODNAME: "Nomen correctionis (facultativum):" MODNAMETIP: "Quaeso, tantum utere litteris Latinis." MODNAMETIP2: "Nomen facultativum correctionis versae (nomen predefinitum est idem conditi ludi)" diff --git a/CK3ToEU4/Data_Files/options_l_russian.yml b/CK3ToEU4/Data_Files/options_l_russian.yml index 43872d41..8f074271 100644 --- a/CK3ToEU4/Data_Files/options_l_russian.yml +++ b/CK3ToEU4/Data_Files/options_l_russian.yml @@ -75,6 +75,12 @@ l_russian: INSTITUTIONS1TIP: "Использовать ванильные появления институтов/выбора идей." INSTITUTIONS2: "Динамичные" INSTITUTIONS2TIP: "Использовать динамичные появления институтов и выбор идей." + DYNASTICNAMES: "Используем ли мы династические имена, когда они доступны?" + DYNASTICNAMESTIP: "В основном для исламских стран, которые используют в названии имя династии." + DYNASTICNAMES1: "Да, я хочу османов." + DYNASTICNAMES1TIP: "Используйте, когда это возможно и уместно." + DYNASTICNAMES2: "Нет, я хочу Турцию." + DYNASTICNAMES2TIP: "Неполноценный." MODNAME: "Имя выхода мода (необязательно):" MODNAMETIP: "Пожалуйста, придерживайтесь латинских букв" MODNAMETIP2: "Необязательное имя для конвертируемого мода (по умолчанию это имя сохраненной игры)" diff --git a/CK3ToEU4/Source/Configuration/Configuration.cpp b/CK3ToEU4/Source/Configuration/Configuration.cpp index ccfe2b39..11d1bddb 100644 --- a/CK3ToEU4/Source/Configuration/Configuration.cpp +++ b/CK3ToEU4/Source/Configuration/Configuration.cpp @@ -115,6 +115,11 @@ void Configuration::registerKeys() multiProvinceDevelopmentTransfer = MULTIPROVDEVTRANSFER(std::stoi(multiprovdevtransferString.getString())); Log(LogLevel::Info) << "Multiple Province Dev Transfer set to: " << multiprovdevtransferString.getString(); }); + registerKeyword("dynasticNames", [this](std::istream& theStream) { + const commonItems::singleString dynasticNamesString(theStream); + dynasticNames = DYNASTICNAMES(std::stoi(dynasticNamesString.getString())); + Log(LogLevel::Info) << "Dynastic Names set to: " << dynasticNamesString.getString(); + }); registerRegex(commonItems::catchallRegex, commonItems::ignoreItem); } diff --git a/CK3ToEU4/Source/Configuration/Configuration.h b/CK3ToEU4/Source/Configuration/Configuration.h index 7e5dd07a..7f5242c1 100644 --- a/CK3ToEU4/Source/Configuration/Configuration.h +++ b/CK3ToEU4/Source/Configuration/Configuration.h @@ -76,6 +76,11 @@ class Configuration: commonItems::parser HISTORIC = 1, DYNAMIC = 2 }; + enum class DYNASTICNAMES + { + ENABLED = 1, + DISABLED = 2 + }; [[nodiscard]] const auto& getSaveGamePath() const { return SaveGamePath; } [[nodiscard]] const auto& getCK3Path() const { return CK3Path; } @@ -95,6 +100,7 @@ class Configuration: commonItems::parser [[nodiscard]] const auto& getMultiProvDevTransfer() const { return multiProvinceDevelopmentTransfer; } [[nodiscard]] const auto& getSplitVassals() const { return splitVassals; } [[nodiscard]] const auto& getPlayerTitle() const { return playerTitle; } + [[nodiscard]] const auto& getDynasticNames() const { return dynasticNames; } void setCraftFlagForPlayerTitle(const std::string& title) { playerTitle = title; } @@ -124,6 +130,7 @@ class Configuration: commonItems::parser MULTIPROVDEVTRANSFER multiProvinceDevelopmentTransfer = MULTIPROVDEVTRANSFER::DEFAULT; DEJURE dejure = DEJURE::ENABLED; SPLITVASSALS splitVassals = SPLITVASSALS::YES; + DYNASTICNAMES dynasticNames = DYNASTICNAMES::ENABLED; std::optional playerTitle; }; diff --git a/CK3ToEU4/Source/EU4World/Country/Country.cpp b/CK3ToEU4/Source/EU4World/Country/Country.cpp index 482a0c03..f8b39554 100644 --- a/CK3ToEU4/Source/EU4World/Country/Country.cpp +++ b/CK3ToEU4/Source/EU4World/Country/Country.cpp @@ -52,7 +52,8 @@ void EU4::Country::initializeFromTitle(const std::string& theTag, const mappers::LocalizationMapper& localizationMapper, const mappers::RulerPersonalitiesMapper& rulerPersonalitiesMapper, date theConversionDate, - Configuration::STARTDATE startDateOption) + Configuration::STARTDATE startDateOption, + bool dynasticNames) { tag = theTag; if (startDateOption == Configuration::STARTDATE::CK) @@ -72,7 +73,7 @@ void EU4::Country::initializeFromTitle(const std::string& theTag, populateHistory(governmentsMapper, religionMapper, provinceMapper, cultureMapper); populateCommons(cultureMapper, localizationMapper); populateMisc(); - populateLocs(localizationMapper); + populateLocs(localizationMapper, dynasticNames); populateRulers(religionMapper, cultureMapper, rulerPersonalitiesMapper, localizationMapper, startDateOption, theConversionDate); } @@ -339,7 +340,7 @@ void EU4::Country::populateMisc() details.excommunicated = true; } -void EU4::Country::populateLocs(const mappers::LocalizationMapper& localizationMapper) +void EU4::Country::populateLocs(const mappers::LocalizationMapper& localizationMapper, bool dynasticNames) { auto nameSet = false; @@ -421,9 +422,10 @@ void EU4::Country::populateLocs(const mappers::LocalizationMapper& localizationM std::set hardcodedExclusions = {"k_rum", "k_israel", "e_india", "e_ilkhanate", "e_persia", "e_mali", "k_mali", "k_ghana", "k_songhay", "e_hre", "e_roman_empire", "e_byzantium"}; - if (details.government == "monarchy" && !hardcodedExclusions.count(title->first) && details.holder->getHouse().first && details.holder->getHouse().second && - details.holder->getHouse().second->getDynasty().second && details.holder->getHouse().second->getDynasty().second->isAppropriateRealmName() && - title->second->getClay() && title->second->getClay()->canBeNamedAfterDynasty() && + if (dynasticNames && details.government == "monarchy" && !hardcodedExclusions.count(title->first) && details.holder->getHouse().first && + details.holder->getHouse().second && details.holder->getHouse().second->getDynasty().second && + details.holder->getHouse().second->getDynasty().second->isAppropriateRealmName() && title->second->getClay() && + title->second->getClay()->canBeNamedAfterDynasty() && (title->second->getLevel() == CK3::LEVEL::KINGDOM || title->second->getLevel() == CK3::LEVEL::EMPIRE)) { const auto& houseName = details.holder->getHouse().second->getName(); @@ -476,8 +478,8 @@ void EU4::Country::populateLocs(const mappers::LocalizationMapper& localizationM adjSet = true; } - // See if we use dynasty name. - if (!adjSet && details.government == "monarchy" && !hardcodedExclusions.count(title->first) && details.holder->getHouse().first && + // Except if needed override for dynasties. See if we use dynasty name. + if (dynasticNames && details.government == "monarchy" && !hardcodedExclusions.count(title->first) && details.holder->getHouse().first && details.holder->getHouse().second->getDynasty().second->isAppropriateRealmName() && (title->second->getLevel() == CK3::LEVEL::KINGDOM || title->second->getLevel() == CK3::LEVEL::EMPIRE)) { @@ -490,7 +492,10 @@ void EU4::Country::populateLocs(const mappers::LocalizationMapper& localizationM newblock.spanish = "de los " + nameLocalizationMatch->spanish; newblock.french = "des " + nameLocalizationMatch->french; newblock.german = nameLocalizationMatch->german + "-"; - localizations.insert(std::pair(tag + "_ADJ", newblock)); + if (localizations.contains(tag + "_ADJ")) + localizations.at(tag + "_ADJ") = newblock; + else + localizations.emplace(tag + "_ADJ", newblock); adjSet = true; } } diff --git a/CK3ToEU4/Source/EU4World/Country/Country.h b/CK3ToEU4/Source/EU4World/Country/Country.h index 0d0b2a51..8972e632 100644 --- a/CK3ToEU4/Source/EU4World/Country/Country.h +++ b/CK3ToEU4/Source/EU4World/Country/Country.h @@ -43,7 +43,8 @@ class Country const mappers::LocalizationMapper& localizationMapper, const mappers::RulerPersonalitiesMapper& rulerPersonalitiesMapper, date theConversionDate, - Configuration::STARTDATE startDateOption); + Configuration::STARTDATE startDateOption, + bool dynasticNames); void setSunsetCountry(bool isSunsetCountry) { details.isSunsetCountry = isSunsetCountry; } void clearHistoryLessons() { details.historyLessons.clear(); } void registerProvince(std::pair> theProvince) { provinces.insert(std::move(theProvince)); } @@ -110,7 +111,7 @@ class Country const mappers::CultureMapper& cultureMapper); void populateCommons(const mappers::CultureMapper& cultureMapper, const mappers::LocalizationMapper& localizationMapper); void populateMisc(); - void populateLocs(const mappers::LocalizationMapper& localizationMapper); + void populateLocs(const mappers::LocalizationMapper& localizationMapper, bool dynasticNames); void populateRulers(const mappers::ReligionMapper& religionMapper, const mappers::CultureMapper& cultureMapper, const mappers::RulerPersonalitiesMapper& rulerPersonalitiesMapper, diff --git a/CK3ToEU4/Source/EU4World/EU4World.cpp b/CK3ToEU4/Source/EU4World/EU4World.cpp index 6aeae42b..d23acd2b 100644 --- a/CK3ToEU4/Source/EU4World/EU4World.cpp +++ b/CK3ToEU4/Source/EU4World/EU4World.cpp @@ -18,6 +18,7 @@ namespace fs = std::filesystem; EU4::World::World(const CK3::World& sourceWorld, const Configuration& theConfiguration, const commonItems::ConverterVersion& converterVersion) { auto invasion = theConfiguration.getSunset() == Configuration::SUNSET::ACTIVE; + auto dynasticNames = theConfiguration.getDynasticNames() == Configuration::DYNASTICNAMES::ENABLED; auto CK3FS = commonItems::ModFilesystem(theConfiguration.getCK3Path(), sourceWorld.getMods()); // Load correct province mappings. @@ -81,7 +82,7 @@ EU4::World::World(const CK3::World& sourceWorld, const Configuration& theConfigu Log(LogLevel::Progress) << "55 %"; // Which happens now. Translating incoming titles into EU4 tags, with new tags being added to our countries. - importCK3Countries(sourceWorld, theConfiguration.getStartDate()); + importCK3Countries(sourceWorld, theConfiguration.getStartDate(), dynasticNames); Log(LogLevel::Progress) << "56 %"; // Now we can deal with provinces since we know to whom to assign them. We first import vanilla province data. @@ -378,7 +379,7 @@ void EU4::World::loadCountriesFromSource(std::istream& theStream, const std::str } } -void EU4::World::importCK3Countries(const CK3::World& sourceWorld, Configuration::STARTDATE startDateOption) +void EU4::World::importCK3Countries(const CK3::World& sourceWorld, Configuration::STARTDATE startDateOption, const bool dynasticNames) { Log(LogLevel::Info) << "-> Importing CK3 Countries"; // countries holds all tags imported from EU4. We'll now overwrite some and @@ -387,32 +388,33 @@ void EU4::World::importCK3Countries(const CK3::World& sourceWorld, Configuration { if (title.second->getLevel() != CK3::LEVEL::EMPIRE) continue; - importCK3Country(title, sourceWorld, startDateOption); + importCK3Country(title, sourceWorld, startDateOption, dynasticNames); } for (const auto& title: sourceWorld.getIndeps()) { if (title.second->getLevel() != CK3::LEVEL::KINGDOM) continue; - importCK3Country(title, sourceWorld, startDateOption); + importCK3Country(title, sourceWorld, startDateOption, dynasticNames); } for (const auto& title: sourceWorld.getIndeps()) { if (title.second->getLevel() != CK3::LEVEL::DUCHY) continue; - importCK3Country(title, sourceWorld, startDateOption); + importCK3Country(title, sourceWorld, startDateOption, dynasticNames); } for (const auto& title: sourceWorld.getIndeps()) { if (title.second->getLevel() != CK3::LEVEL::COUNTY) continue; - importCK3Country(title, sourceWorld, startDateOption); + importCK3Country(title, sourceWorld, startDateOption, dynasticNames); } Log(LogLevel::Info) << ">> " << countries.size() << " total countries recognized."; } void EU4::World::importCK3Country(const std::pair>& title, const CK3::World& sourceWorld, - Configuration::STARTDATE startDateOption) + Configuration::STARTDATE startDateOption, + bool dynasticNames) { // Are we being fed crap? if (!title.second) @@ -470,7 +472,8 @@ void EU4::World::importCK3Country(const std::pairloadEU4Tag(std::pair(*tag, countryItr->second)); } else @@ -486,7 +489,8 @@ void EU4::World::importCK3Country(const std::pairsetGeneratedNation(); title.second->loadEU4Tag(std::pair(*tag, newCountry)); countries.insert(std::pair(*tag, newCountry)); @@ -1242,7 +1246,8 @@ void EU4::World::markHRETag(const Configuration& theConfiguration, localizationMapper, rulerPersonalitiesMapper, conversionDate, - startDateOption); + startDateOption, + false); countries.emplace(actualHRETag, newCountry); } diff --git a/CK3ToEU4/Source/EU4World/EU4World.h b/CK3ToEU4/Source/EU4World/EU4World.h index d6ff98b1..dad5aff1 100644 --- a/CK3ToEU4/Source/EU4World/EU4World.h +++ b/CK3ToEU4/Source/EU4World/EU4World.h @@ -45,10 +45,11 @@ class World void verifyAllCountyMappings(const std::map>& ck3Titles) const; void importVanillaCountries(const std::string& eu4Path, bool invasion); void loadCountriesFromSource(std::istream& theStream, const std::string& sourcePath, bool isVanillaSource); - void importCK3Countries(const CK3::World& sourceWorld, Configuration::STARTDATE startDateOption); + void importCK3Countries(const CK3::World& sourceWorld, Configuration::STARTDATE startDateOption, bool dynasticNames); void importCK3Country(const std::pair>& title, const CK3::World& sourceWorld, - Configuration::STARTDATE startDateOption); + Configuration::STARTDATE startDateOption, + bool dynasticNames); void importVanillaProvinces(const std::string& eu4Path, bool invasion); void importCK3Provinces(const CK3::World& sourceWorld); [[nodiscard]] std::optional>> determineProvinceSource( diff --git a/commonItems b/commonItems index 1d047c30..fc41652c 160000 --- a/commonItems +++ b/commonItems @@ -1 +1 @@ -Subproject commit 1d047c30d2b61e1edfa4b2a16e1d3cbad179c879 +Subproject commit fc41652cc1312391e7afcbf17c197e59ae0d0a6f