Auto-build default team colors list
This commit is contained in:
parent
b0510bfdc7
commit
4c5bf2dae2
7 changed files with 41 additions and 29 deletions
|
@ -12,6 +12,7 @@
|
|||
id=red
|
||||
rgb=FF0000,FFFFFF,000000,FF0000
|
||||
name= _ "Red"
|
||||
default=yes
|
||||
[/color_range]
|
||||
|
||||
[color_range]
|
||||
|
@ -30,6 +31,7 @@
|
|||
id=blue
|
||||
rgb=2E419B,FFFFFF,0F0F0F,0000FF
|
||||
name= _ "Blue"
|
||||
default=yes
|
||||
[/color_range]
|
||||
|
||||
[color_range]
|
||||
|
@ -42,6 +44,7 @@
|
|||
id=green
|
||||
rgb=62B664,FFFFFF,000000,00FF00
|
||||
name= _ "Green"
|
||||
default=yes
|
||||
[/color_range]
|
||||
|
||||
[color_range]
|
||||
|
@ -54,24 +57,28 @@
|
|||
id=purple
|
||||
rgb=93009D,FFFFFF,000000,FF00FF
|
||||
name= _ "Purple"
|
||||
default=yes
|
||||
[/color_range]
|
||||
|
||||
[color_range]
|
||||
id=black
|
||||
rgb=5A5A5A,FFFFFF,000000,000000
|
||||
name= _ "Black"
|
||||
default=yes
|
||||
[/color_range]
|
||||
|
||||
[color_range]
|
||||
id=brown
|
||||
rgb=945027,FFFFFF,000000,AA4600
|
||||
name= _ "Brown"
|
||||
default=yes
|
||||
[/color_range]
|
||||
|
||||
[color_range]
|
||||
id=orange
|
||||
rgb=FF7E00,FFFFFF,0F0F0F,FFAA00
|
||||
name= _ "Orange"
|
||||
default=yes
|
||||
[/color_range]
|
||||
|
||||
[color_range]
|
||||
|
@ -84,12 +91,14 @@
|
|||
id=white
|
||||
rgb=E1E1E1,FFFFFF,1E1E1E,FFFFFF
|
||||
name= _ "White"
|
||||
default=yes
|
||||
[/color_range]
|
||||
|
||||
[color_range]
|
||||
id=teal
|
||||
rgb=30CBC0,FFFFFF,000000,00F0C8
|
||||
name= _ "Teal"
|
||||
default=yes
|
||||
[/color_range]
|
||||
|
||||
[color_range]
|
||||
|
|
|
@ -54,11 +54,6 @@
|
|||
ally_orb_color="lightblue"
|
||||
partial_orb_color="brightorange"
|
||||
moved_orb_color="red"
|
||||
|
||||
# NOTE: this list should match the order in which the corresponding [color_range] tags appear
|
||||
# in core/team-colors.cfg, or else any index from this list used to recolor a sprite
|
||||
# will not produce the correct color.
|
||||
default_color_list="red,blue,green,purple,black,brown,orange,white,teal"
|
||||
[/colors]
|
||||
|
||||
[images]
|
||||
|
|
|
@ -257,6 +257,11 @@ std::string
|
|||
|
||||
} // sounds
|
||||
|
||||
static void add_color_info(const config& v, bool build_defaults);
|
||||
void add_color_info(const config& v)
|
||||
{
|
||||
add_color_info(v, false);
|
||||
}
|
||||
|
||||
void load_config(const config &v)
|
||||
{
|
||||
|
@ -293,7 +298,6 @@ void load_config(const config &v)
|
|||
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);
|
||||
|
@ -344,7 +348,7 @@ void load_config(const config &v)
|
|||
shroud_prefix = v["shroud_prefix"].str();
|
||||
fog_prefix = v["fog_prefix"].str();
|
||||
|
||||
add_color_info(v);
|
||||
add_color_info(v, true);
|
||||
|
||||
if(const config::attribute_value* a = v.get("flag_rgb")) {
|
||||
flag_rgb = a->str();
|
||||
|
@ -418,8 +422,12 @@ void load_config(const config &v)
|
|||
}
|
||||
}
|
||||
|
||||
void add_color_info(const config& v)
|
||||
void add_color_info(const config& v, bool build_defaults)
|
||||
{
|
||||
if(build_defaults) {
|
||||
default_colors.clear();
|
||||
}
|
||||
|
||||
for(const config& teamC : v.child_range("color_range")) {
|
||||
const config::attribute_value* a1 = teamC.get("id"), *a2 = teamC.get("rgb");
|
||||
if(!a1 || !a2) {
|
||||
|
@ -440,17 +448,19 @@ void add_color_info(const config& v)
|
|||
}
|
||||
|
||||
team_rgb_range.emplace(id, color_range(temp));
|
||||
team_rgb_name[id] = teamC["name"];
|
||||
team_rgb_name.emplace(id, teamC["name"].t_str());
|
||||
|
||||
LOG_NG << "registered color range '" << id << "': " << team_rgb_range[id].debug() << '\n';
|
||||
|
||||
// Ggenerate palette of same name;
|
||||
std::vector<color_t> tp = palette(team_rgb_range[id]);
|
||||
if(tp.empty()) {
|
||||
continue;
|
||||
if(!tp.empty()) {
|
||||
team_rgb_colors.emplace(id, tp);
|
||||
}
|
||||
|
||||
team_rgb_colors.emplace(id, tp);
|
||||
if(build_defaults && teamC["default"].to_bool()) {
|
||||
default_colors.push_back(*a1);
|
||||
}
|
||||
}
|
||||
|
||||
for(const config &cp : v.child_range("color_palette")) {
|
||||
|
@ -468,14 +478,14 @@ void add_color_info(const config& v)
|
|||
LOG_NG << "registered color palette: " << rgb.first << '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void reset_color_info()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
team_rgb_colors.clear();
|
||||
team_rgb_name.clear();
|
||||
team_rgb_range.clear();
|
||||
}
|
||||
|
||||
const color_range& color_info(const std::string& name)
|
||||
|
|
|
@ -169,6 +169,7 @@ namespace game_config
|
|||
void load_config(const config &cfg);
|
||||
|
||||
void add_color_info(const config& v);
|
||||
void reset_color_info();
|
||||
const std::vector<color_t>& tc_info(const std::string& name);
|
||||
const color_range& color_info(const std::string& name);
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ bool game_config_manager::init_game_config(FORCE_RELOAD_CONFIG force_reload)
|
|||
game_config::scoped_preproc_define title_screen("TITLE_SCREEN",
|
||||
!cmdline_opts_.multiplayer && !cmdline_opts_.test && !jump_to_editor_);
|
||||
|
||||
game_config::reset_color_info();
|
||||
load_game_config_with_loadscreen(force_reload);
|
||||
|
||||
game_config::load_config(game_config_.child("game_config"));
|
||||
|
@ -291,8 +292,8 @@ void game_config_manager::load_game_config(FORCE_RELOAD_CONFIG force_reload,
|
|||
game_config_.splice_children(core_terrain_rules, "terrain_graphics");
|
||||
|
||||
set_multiplayer_hashes();
|
||||
set_color_info();
|
||||
set_unit_data();
|
||||
game_config::add_color_info(game_config_);
|
||||
|
||||
terrain_builder::set_terrain_rules_cfg(game_config());
|
||||
tdata_ = std::make_shared<terrain_type_data>(game_config_);
|
||||
|
@ -466,14 +467,6 @@ void game_config_manager::set_multiplayer_hashes()
|
|||
}
|
||||
}
|
||||
|
||||
void game_config_manager::set_color_info()
|
||||
{
|
||||
config colorsys_info;
|
||||
colorsys_info.splice_children(game_config_, "color_range");
|
||||
colorsys_info.splice_children(game_config_, "color_palette");
|
||||
game_config::add_color_info(colorsys_info);
|
||||
}
|
||||
|
||||
void game_config_manager::set_unit_data()
|
||||
{
|
||||
game_config_.merge_children("units");
|
||||
|
|
|
@ -65,7 +65,6 @@ private:
|
|||
// load_game_config() helper functions.
|
||||
void load_addons_cfg();
|
||||
void set_multiplayer_hashes();
|
||||
void set_color_info();
|
||||
void set_unit_data();
|
||||
|
||||
const commandline_options& cmdline_opts_;
|
||||
|
|
|
@ -238,7 +238,12 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
|
||||
int side = (resources::gameboard ? resources::gameboard->village_owner(loc) : -1); //check needed for mp create dialog
|
||||
|
||||
color_t col = game_config::team_rgb_range.find("white")->second.min();
|
||||
// TODO: Add a key to [game_config][colors] for this
|
||||
auto iter = game_config::team_rgb_range.find("white");
|
||||
color_t col(255,255,255);
|
||||
if(iter != game_config::team_rgb_range.end()) {
|
||||
col = iter->second.min();
|
||||
}
|
||||
|
||||
if (!fogged) {
|
||||
if (side > -1) {
|
||||
|
|
Loading…
Add table
Reference in a new issue