Game Config: added default_color_list= key

This key contains the color range ids of the standard colors in the default order.

Previously, classes such as the connect_engine would have to cast ints to strings and browse for the numerically id-ed
color ranges. Consequently, since there are only 9 ranges identified by that method, 9 became a hardcoded number of
colors in certain places. This key allows for greater control over order and content of the default colors.
This commit is contained in:
Charles Dang 2016-10-12 01:04:05 +11:00
parent 066c34ae5e
commit 396267c900
3 changed files with 19 additions and 2 deletions

View file

@ -53,6 +53,8 @@
ally_orb_color="lightblue"
partial_orb_color="brightorange"
moved_orb_color="red"
default_color_list="red,blue,green,purple,orange,black,white,brown,teal"
[/colors]
[images]

View file

@ -75,7 +75,8 @@ namespace game_config
unmoved_orb_color,
partial_orb_color,
enemy_orb_color,
ally_orb_color;
ally_orb_color,
default_color_list;
}
bool show_ally_orb, show_enemy_orb, show_moved_orb, show_partial_orb, show_unmoved_orb;
@ -140,6 +141,8 @@ namespace game_config
std::map<std::string, std::vector<uint32_t> > team_rgb_colors;
std::vector<std::string> default_colors;
const version_info wesnoth_version(VERSION);
const version_info min_savegame_version(MIN_SAVEGAME_VERSION);
const version_info test_version("test");
@ -215,6 +218,7 @@ namespace game_config
partial_orb_color = i["partial_orb_color"].str();
enemy_orb_color = i["enemy_orb_color"].str();
ally_orb_color = i["ally_orb_color"].str();
default_color_list = i["default_color_list"].str();
} // colors
show_ally_orb = v["show_ally_orb"].to_bool(true);
@ -379,6 +383,14 @@ namespace game_config
LOG_NG << "registered color palette: " << rgb.first << '\n';
}
}
default_colors.clear();
for(const auto& color : utils::split(game_config::colors::default_color_list)) {
if(team_rgb_name.find(color) != team_rgb_name.end()) {
default_colors.push_back(color);
}
}
}
const color_range& color_info(const std::string& name)

View file

@ -77,7 +77,8 @@ namespace game_config
partial_orb_color,
enemy_orb_color,
ally_orb_color,
moved_orb_color;
moved_orb_color,
default_color_list;
} // colors
extern bool show_ally_orb, show_enemy_orb, show_moved_orb, show_partial_orb, show_unmoved_orb;
@ -136,6 +137,8 @@ namespace game_config
extern std::map<std::string, t_string> team_rgb_name;
extern std::map<std::string, std::vector<uint32_t> > team_rgb_colors;
extern std::vector<std::string> default_colors;
/** observer team name used for observer team chat */
extern const std::string observer_team_name;