aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/openvic-simulation/country/Country.cpp44
-rw-r--r--src/openvic-simulation/country/Country.hpp12
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.cpp7
3 files changed, 52 insertions, 11 deletions
diff --git a/src/openvic-simulation/country/Country.cpp b/src/openvic-simulation/country/Country.cpp
index 463d1bf..2b022b0 100644
--- a/src/openvic-simulation/country/Country.cpp
+++ b/src/openvic-simulation/country/Country.cpp
@@ -24,17 +24,33 @@ CountryParty::CountryParty(
policies { std::move(new_policies) } {}
Country::Country(
- std::string_view new_identifier, colour_t new_colour, GraphicalCultureType const& new_graphical_culture,
- IdentifierRegistry<CountryParty>&& new_parties, unit_names_map_t&& new_unit_names, bool new_dynamic_tag,
- government_colour_map_t&& new_alternative_colours
-) : HasIdentifierAndColour { new_identifier, new_colour, false }, graphical_culture { new_graphical_culture },
- parties { std::move(new_parties) }, unit_names { std::move(new_unit_names) }, dynamic_tag { new_dynamic_tag },
- alternative_colours { std::move(new_alternative_colours) } {}
+ std::string_view new_identifier,
+ colour_t new_colour,
+ GraphicalCultureType const& new_graphical_culture,
+ IdentifierRegistry<CountryParty>&& new_parties,
+ unit_names_map_t&& new_unit_names,
+ bool new_dynamic_tag,
+ government_colour_map_t&& new_alternative_colours,
+ colour_t new_primary_unit_colour,
+ colour_t new_secondary_unit_colour,
+ colour_t new_tertiary_unit_colour
+) : HasIdentifierAndColour {
+ new_identifier, new_colour, false },
+ graphical_culture { new_graphical_culture },
+ parties { std::move(new_parties) },
+ unit_names { std::move(new_unit_names) },
+ dynamic_tag { new_dynamic_tag },
+ alternative_colours { std::move(new_alternative_colours) },
+ primary_unit_colour { new_primary_unit_colour },
+ secondary_unit_colour { new_secondary_unit_colour },
+ tertiary_unit_colour { new_tertiary_unit_colour }
+ {}
bool CountryManager::add_country(
std::string_view identifier, colour_t colour, GraphicalCultureType const* graphical_culture,
IdentifierRegistry<CountryParty>&& parties, Country::unit_names_map_t&& unit_names, bool dynamic_tag,
- Country::government_colour_map_t&& alternative_colours
+ Country::government_colour_map_t&& alternative_colours,
+ colour_t primary_unit_colour, colour_t secondary_unit_colour, colour_t tertiary_unit_colour
) {
if (identifier.empty()) {
Logger::error("Invalid country identifier - empty!");
@@ -53,7 +69,7 @@ bool CountryManager::add_country(
return countries.add_item({
identifier, colour, *graphical_culture, std::move(parties), std::move(unit_names), dynamic_tag,
- std::move(alternative_colours)
+ std::move(alternative_colours), primary_unit_colour, secondary_unit_colour, tertiary_unit_colour
});
}
@@ -101,6 +117,16 @@ bool CountryManager::load_countries(GameManager const& game_manager, Dataloader
return ret;
}
+bool CountryManager::load_country_colours(ast::NodeCPtr root){
+ return countries.expect_item_dictionary([](Country& country, ast::NodeCPtr colour_node) -> bool {
+ return expect_dictionary_keys(
+ "color1", ONE_EXACTLY, expect_colour(assign_variable_callback(country.primary_unit_colour)),
+ "color2", ONE_EXACTLY, expect_colour(assign_variable_callback(country.secondary_unit_colour)),
+ "color3", ONE_EXACTLY, expect_colour(assign_variable_callback(country.tertiary_unit_colour))
+ )(colour_node);
+ })(root);
+}
+
node_callback_t CountryManager::load_country_party(
PoliticsManager const& politics_manager, IdentifierRegistry<CountryParty>& country_parties
) const {
@@ -180,7 +206,7 @@ bool CountryManager::load_country_data_file(
ret &= add_country(
name, colour, graphical_culture, std::move(parties), std::move(unit_names), is_dynamic,
- std::move(alternative_colours)
+ std::move(alternative_colours), colour_t::null(), colour_t::null(), colour_t::null()
);
return ret;
}
diff --git a/src/openvic-simulation/country/Country.hpp b/src/openvic-simulation/country/Country.hpp
index 5f60534..fd6fa7e 100644
--- a/src/openvic-simulation/country/Country.hpp
+++ b/src/openvic-simulation/country/Country.hpp
@@ -63,11 +63,16 @@ namespace OpenVic {
const unit_names_map_t PROPERTY(unit_names);
const bool PROPERTY_CUSTOM_PREFIX(dynamic_tag, is);
const government_colour_map_t PROPERTY(alternative_colours);
+ colour_t PROPERTY(primary_unit_colour);
+ colour_t PROPERTY(secondary_unit_colour);
+ colour_t PROPERTY(tertiary_unit_colour);
+ // Unit colours not const due to being added after construction
Country(
std::string_view new_identifier, colour_t new_colour, GraphicalCultureType const& new_graphical_culture,
IdentifierRegistry<CountryParty>&& new_parties, unit_names_map_t&& new_unit_names, bool new_dynamic_tag,
- government_colour_map_t&& new_alternative_colours
+ government_colour_map_t&& new_alternative_colours,
+ colour_t new_primary_unit_colour, colour_t new_secondary_unit_colour, colour_t new_tertiary_unit_colour
);
public:
@@ -88,9 +93,12 @@ namespace OpenVic {
bool add_country(
std::string_view identifier, colour_t colour, GraphicalCultureType const* graphical_culture,
IdentifierRegistry<CountryParty>&& parties, Country::unit_names_map_t&& unit_names, bool dynamic_tag,
- Country::government_colour_map_t&& alternative_colours
+ Country::government_colour_map_t&& alternative_colours,
+ colour_t primary_unit_colour, colour_t secondary_unit_colour, colour_t tertiary_unit_colour
);
+ bool load_country_colours(ast::NodeCPtr root);
+
bool load_countries(GameManager const& game_manager, Dataloader const& dataloader, ast::NodeCPtr root);
bool load_country_data_file(
GameManager const& game_manager, std::string_view name, bool is_dynamic, ast::NodeCPtr root
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp
index 157ff04..56cf40c 100644
--- a/src/openvic-simulation/dataloader/Dataloader.cpp
+++ b/src/openvic-simulation/dataloader/Dataloader.cpp
@@ -808,6 +808,7 @@ bool Dataloader::load_defines(GameManager& game_manager) {
static constexpr std::string_view buildings_file = "common/buildings.txt";
static constexpr std::string_view bookmark_file = "common/bookmarks.txt";
static constexpr std::string_view countries_file = "common/countries.txt";
+ static constexpr std::string_view country_colours_file = "common/country_colors.txt";
static constexpr std::string_view culture_file = "common/cultures.txt";
static constexpr std::string_view governments_file = "common/governments.txt";
static constexpr std::string_view graphical_culture_type_file = "common/graphicalculturetype.txt";
@@ -985,6 +986,12 @@ bool Dataloader::load_defines(GameManager& game_manager) {
Logger::error("Failed to load countries!");
ret = false;
}
+ if (!game_manager.get_country_manager().load_country_colours(
+ parse_defines(lookup_file(country_colours_file)).get_file_node()
+ )) {
+ Logger::error("Failed to load country colours!");
+ ret = false;
+ }
if (!game_manager.get_pop_manager().get_culture_manager().load_culture_file(
game_manager.get_country_manager(), parse_defines(lookup_file(culture_file)).get_file_node()
)) {