From 35b4fa2e5c6c7fd082493ec143cf236da69f7ba1 Mon Sep 17 00:00:00 2001 From: Arturo <69714460+Jarturog@users.noreply.github.com> Date: Sun, 18 Feb 2024 21:27:58 +0100 Subject: Regions are now coloured from colors.txt --- src/openvic-simulation/dataloader/Dataloader.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/openvic-simulation/dataloader') diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp index 157ff04..e1bf093 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 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)) { -- cgit v1.2.3-56-ga3b1