aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/dataloader
diff options
context:
space:
mode:
author Arturo <69714460+Jarturog@users.noreply.github.com>2024-02-22 22:22:25 +0100
committer GitHub <noreply@github.com>2024-02-22 22:22:25 +0100
commit164e76e367ff7dc5914f0d7105b5914fd3fba90a (patch)
treece02787f870da7584fb9ea275efa53d98431b7c2 /src/openvic-simulation/dataloader
parent147e0a772dc768bd90fdccdd2536f14c11238d57 (diff)
parent35b4fa2e5c6c7fd082493ec143cf236da69f7ba1 (diff)
Merge pull request #148 from OpenVicProject/region-colours
Regions are now coloured from colors.txt
Diffstat (limited to 'src/openvic-simulation/dataloader')
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp
index 56cf40c..b7ccba3 100644
--- a/src/openvic-simulation/dataloader/Dataloader.cpp
+++ b/src/openvic-simulation/dataloader/Dataloader.cpp
@@ -683,6 +683,8 @@ bool Dataloader::_load_map_dir(GameManager& game_manager) const {
static constexpr std::string_view default_province_flag_sprite = "province_flag_sprites"; /* Canal sprite/model names. */
static constexpr std::string_view climate_file = "climate.txt";
+ static constexpr std::string_view region_colours = "interface/colors.txt"; /* This file is not in map_directory */
+
/* Parser stored so the filename string_views persist until the end of this function. */
const v2script::Parser parser = parse_defines(lookup_file(append_string_views(map_directory, defaults_filename)));
@@ -735,9 +737,21 @@ bool Dataloader::_load_map_dir(GameManager& game_manager) const {
ret = false;
}
- if (!map.load_region_file(parse_defines(lookup_file(append_string_views(map_directory, region))).get_file_node())) {
- Logger::error("Failed to load region file!");
- ret = false;
+ {
+ std::vector<colour_t> colours;
+ if (!Map::load_region_colours(parse_defines(lookup_file(region_colours)).get_file_node(), colours)) {
+ Logger::error("Failed to load region colours file!");
+ ret = false;
+ }
+
+ using namespace OpenVic::colour_literals;
+ colours.push_back(0xFFFFFF_rgb); /* This ensures there is always at least one region colour. */
+
+ if (!map.load_region_file(
+ parse_defines(lookup_file(append_string_views(map_directory, region))).get_file_node(), colours)) {
+ Logger::error("Failed to load region file!");
+ ret = false;
+ }
}
if (!map.set_water_province_list(water_province_identifiers)) {