MP Join Game: colorize side numbers instead of a separate color orb display

This commit is contained in:
Charles Dang 2016-10-12 13:40:42 +11:00
parent a027f3f6ee
commit f1d2488529

View file

@ -299,9 +299,16 @@ void tmp_join_game::pre_show(twindow& window)
find_widget<tbutton>(&window, "ok", false).set_visible(twidget::tvisible::hidden);
}
/*
* We don't need the full widget setup as is done initially, just value setters.
*/
static std::string get_pango_color_from_id(const std::string& id)
{
const auto color = game_config::team_rgb_colors.find(id);
if(color != game_config::team_rgb_colors.end()) {
return rgb2highlight_pango(color->second[0]);
}
return "";
}
void tmp_join_game::generate_side_list(twindow& window)
{
if(stop_updates_) {
@ -337,7 +344,9 @@ void tmp_join_game::generate_side_list(twindow& window)
std::map<std::string, string_map> data;
string_map item;
item["label"] = side["side"];
const std::string color = !side["color"].empty() ? side["color"] : side["side"].str();
item["label"] = (formatter() << "<span color='" << get_pango_color_from_id(color) << "'>" << side["side"] << "</span>").str();
data.emplace("side_number", item);
std::string leader_image = ng::random_enemy_picture;
@ -358,8 +367,6 @@ void tmp_join_game::generate_side_list(twindow& window)
if(const unit_type* ut = unit_types.find(leader_type)) {
const unit_type& type = ut->get_gender_unit_type(leader_gender);
const std::string color = !side["color"].empty() ? side["color"] : side["side"].str();
leader_image = formatter() << type.image() << "~RC(" << type.flag_rgb() << ">" << color << ")";
leader_name = type.type_name();
}
@ -404,9 +411,6 @@ void tmp_join_game::generate_side_list(twindow& window)
data.emplace("side_income", item);
}
item["label"] = (formatter() << "buttons/misc/orb-active.png~RC(magenta>" << side["color"] << ")").str();
data.emplace("side_color", item);
ttree_view_node& node = team_tree_map_[side["team_name"].str()]->add_child("side_panel", data);
tgrid& row_grid = node.get_grid();