diff --git a/lib/campaign/CampaignState.cpp b/lib/campaign/CampaignState.cpp index e69679f3a..1a7980fee 100644 --- a/lib/campaign/CampaignState.cpp +++ b/lib/campaign/CampaignState.cpp @@ -46,6 +46,8 @@ CampaignRegions CampaignRegions::fromJson(const JsonNode & node) CampaignRegions cr; cr.campPrefix = node["prefix"].String(); cr.colorSuffixLength = static_cast(node["color_suffix_length"].Float()); + cr.campSuffix = node["suffix"].isNull() ? std::vector() : std::vector{node["suffix"].Vector()[0].String(), node["suffix"].Vector()[1].String(), node["suffix"].Vector()[2].String()}; + cr.campBackground = node["background"].isNull() ? "" : node["background"].String(); for(const JsonNode & desc : node["desc"].Vector()) cr.regions.push_back(CampaignRegions::RegionDescription::fromJson(desc)); @@ -68,7 +70,10 @@ CampaignRegions CampaignRegions::getLegacy(int campId) ImagePath CampaignRegions::getBackgroundName() const { - return ImagePath::builtin(campPrefix + "_BG.BMP"); + if(campBackground.empty()) + return ImagePath::builtin(campPrefix + "_BG.BMP"); + else + return ImagePath::builtin(campBackground); } Point CampaignRegions::getPosition(CampaignScenarioID which) const @@ -81,30 +86,40 @@ ImagePath CampaignRegions::getNameFor(CampaignScenarioID which, int colorIndex, { auto const & region = regions[which.getNum()]; - static const std::string colors[2][8] = + static const std::string colors[3][8] = { + {"", "", "", "", "", "", "", ""}, {"R", "B", "N", "G", "O", "V", "T", "P"}, {"Re", "Bl", "Br", "Gr", "Or", "Vi", "Te", "Pi"} }; - std::string color = colors[colorSuffixLength - 1][colorIndex]; + std::string color = colors[colorSuffixLength][colorIndex]; return ImagePath::builtin(campPrefix + region.infix + "_" + type + color + ".BMP"); } ImagePath CampaignRegions::getAvailableName(CampaignScenarioID which, int color) const { - return getNameFor(which, color, "En"); + if(campSuffix.size() == 0) + return getNameFor(which, color, "En"); + else + return getNameFor(which, color, campSuffix[0]); } ImagePath CampaignRegions::getSelectedName(CampaignScenarioID which, int color) const { - return getNameFor(which, color, "Se"); + if(campSuffix.size() == 0) + return getNameFor(which, color, "Se"); + else + return getNameFor(which, color, campSuffix[1]); } ImagePath CampaignRegions::getConqueredName(CampaignScenarioID which, int color) const { - return getNameFor(which, color, "Co"); + if(campSuffix.size() == 0) + return getNameFor(which, color, "Co"); + else + return getNameFor(which, color, campSuffix[2]); } diff --git a/lib/campaign/CampaignState.h b/lib/campaign/CampaignState.h index 3da0ce4d9..c46382b2f 100644 --- a/lib/campaign/CampaignState.h +++ b/lib/campaign/CampaignState.h @@ -33,6 +33,8 @@ class IGameCallback; class DLL_LINKAGE CampaignRegions { std::string campPrefix; + std::vector campSuffix = {}; + std::string campBackground = ""; int colorSuffixLength; struct DLL_LINKAGE RegionDescription @@ -67,6 +69,11 @@ public: h & campPrefix; h & colorSuffixLength; h & regions; + if (h.version >= Handler::Version::CAMPAIGN_REGIONS) + { + h & campSuffix; + h & campBackground; + } } static CampaignRegions fromJson(const JsonNode & node); diff --git a/lib/serializer/ESerializationVersion.h b/lib/serializer/ESerializationVersion.h index 853bcde7e..0a47355c0 100644 --- a/lib/serializer/ESerializationVersion.h +++ b/lib/serializer/ESerializationVersion.h @@ -58,7 +58,8 @@ enum class ESerializationVersion : int32_t MAP_FORMAT_ADDITIONAL_INFOS, // 848 - serialize new infos in map format REMOVE_LIB_RNG, // 849 - removed random number generators from library classes HIGHSCORE_PARAMETERS, // 850 - saves parameter for campaign - PLAYER_HANDICAP, // 851 - player handicap selection at game start + PLAYER_HANDICAP, // 851 - player handicap selection at game start + CAMPAIGN_REGIONS, // 852 - configurable campaign regions CURRENT = PLAYER_HANDICAP };