本文整理汇总了C++中reports::context::teams方法的典型用法代码示例。如果您正苦于以下问题:C++ context::teams方法的具体用法?C++ context::teams怎么用?C++ context::teams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reports::context
的用法示例。
在下文中一共展示了context::teams方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unit_side
static config unit_side(reports::context & rc, const unit* u)
{
if (!u) return config();
config report;
const team &u_team = rc.teams()[u->side() - 1];
std::string flag_icon = u_team.flag_icon();
std::string old_rgb = game_config::flag_rgb;
std::string new_rgb = team::get_side_color_index(u->side());
std::string mods = "~RC(" + old_rgb + ">" + new_rgb + ")";
if (flag_icon.empty())
flag_icon = game_config::images::flag_icon;
std::stringstream text;
text << " " << u->side();
add_image(report, flag_icon + mods, u_team.current_player(), "");
add_text(report, text.str(), "", "");
return report;
}
示例2: time_of_day_at
static config time_of_day_at(reports::context & rc, const map_location& mouseover_hex)
{
std::ostringstream tooltip;
time_of_day tod;
const team &viewing_team = rc.teams()[rc.screen().viewing_team()];
if (viewing_team.shrouded(mouseover_hex)) {
// Don't show time on shrouded tiles.
tod = rc.tod().get_time_of_day();
} else if (viewing_team.fogged(mouseover_hex)) {
// Don't show illuminated time on fogged tiles.
tod = rc.tod().get_time_of_day(mouseover_hex);
} else {
tod = rc.tod().get_illuminated_time_of_day(rc.units(), rc.map(), mouseover_hex);
}
int b = tod.lawful_bonus;
std::string lawful_color("white");
std::string chaotic_color("white");
std::string liminal_color("white");
if (b != 0) {
lawful_color = (b > 0) ? "green" : "red";
chaotic_color = (b < 0) ? "green" : "red";
liminal_color = "red";
}
tooltip << tod.name << '\n'
<< _("Lawful units: ") << "<span foreground=\"" << lawful_color << "\">"
<< utils::signed_percent(b) << "</span>\n"
<< _("Neutral units: ") << utils::signed_percent(0) << '\n'
<< _("Chaotic units: ") << "<span foreground=\"" << chaotic_color << "\">"
<< utils::signed_percent(-b) << "</span>\n"
<< _("Liminal units: ") << "<span foreground=\"" << liminal_color << "\">"
<< utils::signed_percent(-(abs(b))) << "</span>\n";
std::string tod_image = tod.image;
if (tod.bonus_modified > 0) tod_image += "~BRIGHTEN()";
else if (tod.bonus_modified < 0) tod_image += "~DARKEN()";
return image_report(tod_image, tooltip.str(), "time_of_day_" + tod.id);
}
示例3: attack_info
//.........这里部分代码省略.........
// Regular swarm
tooltip << '\t' << _("Base attacks: ") << base_attacks << '\n';
if ( max_attacks != base_attacks ) {
tooltip << '\t' << _("With specials: ") << max_attacks << '\n';
}
if ( min_attacks != 0 ) {
tooltip << '\t' << _("Subject to swarm: ") << (max_attacks-min_attacks) << '\n';
}
tooltip << '\t' << _("Swarm: ") << "* "<< (cur_hp*100/max_hp) << "%\n";
}
}
else if ( num_attacks != base_attacks ) {
tooltip << '\t' << _("Base attacks: ") << base_attacks << '\n';
tooltip << '\t' << _("With specials: ") << num_attacks << '\n';
}
add_text(res, flush(str), flush(tooltip));
std::string range = string_table["range_" + at.range()];
std::string lang_type = string_table["type_" + at.type()];
str << span_color(font::weapon_details_color) << " " << " "
<< range << font::weapon_details_sep
<< lang_type << "</span>\n";
tooltip << _("Weapon range: ") << "<b>" << range << "</b>\n"
<< _("Damage type: ") << "<b>" << lang_type << "</b>\n"
<< _("Damage versus: ") << '\n';
// Show this weapon damage and resistance against all the different units.
// We want weak resistances (= good damage) first.
std::map<int, std::set<std::string>, std::greater<int> > resistances;
std::set<std::string> seen_types;
const team &unit_team = rc.teams()[u.side() - 1];
const team &viewing_team = rc.teams()[rc.screen().viewing_team()];
for (const unit &enemy : rc.units())
{
if (enemy.incapacitated()) //we can't attack statues so don't display them in this tooltip
continue;
if (!unit_team.is_enemy(enemy.side()))
continue;
const map_location &loc = enemy.get_location();
if (viewing_team.fogged(loc) ||
(viewing_team.is_enemy(enemy.side()) && enemy.invisible(loc)))
continue;
bool new_type = seen_types.insert(enemy.type_id()).second;
if (new_type) {
int resistance = enemy.resistance_against(at, false, loc);
resistances[resistance].insert(enemy.type_name());
}
}
typedef std::pair<int, std::set<std::string> > resist_units;
for (const resist_units &resist : resistances) {
int damage = round_damage(specials_damage, damage_multiplier * resist.first, damage_divisor);
tooltip << "<b>" << damage << "</b> "
<< "<i>(" << utils::signed_percent(resist.first-100) << ")</i> : "
<< utils::join(resist.second, ", ") << '\n';
}
add_text(res, flush(str), flush(tooltip));
const std::string &accuracy_parry = at.accuracy_parry_description();
if (!accuracy_parry.empty())
{
str << span_color(font::weapon_details_color)
<< " " << accuracy_parry << "</span>\n";
示例4: unit_box_at
static config unit_box_at(reports::context & rc, const map_location& mouseover_hex)
{
std::ostringstream tooltip;
time_of_day local_tod;
time_of_day global_tod = rc.tod().get_time_of_day();
const team &viewing_team = rc.teams()[rc.screen().viewing_team()];
if (viewing_team.shrouded(mouseover_hex)) {
// Don't show time on shrouded tiles.
local_tod = global_tod;
} else if (viewing_team.fogged(mouseover_hex)) {
// Don't show illuminated time on fogged tiles.
local_tod = rc.tod().get_time_of_day(mouseover_hex);
} else {
local_tod = rc.tod().get_illuminated_time_of_day(rc.units(), rc.map(),mouseover_hex);
}
int bonus = local_tod.lawful_bonus;
std::string lawful_color("white");
std::string chaotic_color("white");
std::string liminal_color("white");
if (bonus != 0) {
lawful_color = (bonus > 0) ? "green" : "red";
chaotic_color = (bonus < 0) ? "green" : "red";
liminal_color = "red";
}
tooltip << local_tod.name << '\n'
<< _("Lawful units: ") << "<span foreground=\"" << lawful_color << "\">"
<< utils::signed_percent(bonus) << "</span>\n"
<< _("Neutral units: ") << utils::signed_percent(0) << '\n'
<< _("Chaotic units: ") << "<span foreground=\"" << chaotic_color << "\">"
<< utils::signed_percent(-bonus) << "</span>\n"
<< _("Liminal units: ") << "<span foreground=\"" << liminal_color << "\">"
<< utils::signed_percent(-(abs(bonus))) << "</span>\n";
std::string local_tod_image = "themes/classic/" + local_tod.image;
std::string global_tod_image = "themes/classic/" + global_tod.image;
if (local_tod.bonus_modified > 0) local_tod_image += "~BRIGHTEN()";
else if (local_tod.bonus_modified < 0) local_tod_image += "~DARKEN()";
const gamemap &map = rc.map();
t_translation::t_terrain terrain = map.get_terrain(mouseover_hex);
//if (terrain == t_translation::OFF_MAP_USER)
// return config();
//if (map.is_keep(mouseover_hex)) {
// add_image(cfg, "icons/terrain/terrain_type_keep.png", "");
//}
const t_translation::t_list& underlying_terrains = map.underlying_union_terrain(terrain);
std::string bg_terrain_image;
for (const t_translation::t_terrain& underlying_terrain : underlying_terrains) {
const std::string& terrain_id = map.get_terrain_info(underlying_terrain).id();
bg_terrain_image = "~BLIT(unit_env/terrain/terrain-" + terrain_id + ".png)" + bg_terrain_image;
}
std::stringstream color;
color << local_tod.color;
bg_terrain_image = bg_terrain_image + "~CS(" + color.str() + ")";
const unit *u = get_visible_unit(rc);
std::string unit_image;
if (u)
unit_image = "~BLIT(" + u->absolute_image() + u->image_mods() + ",35,22)";
std::string tod_image = global_tod_image + "~BLIT(" + local_tod_image + ")";
return image_report(tod_image + bg_terrain_image + unit_image, tooltip.str(), "time_of_day");
}