本文整理汇总了C++中unit::gender方法的典型用法代码示例。如果您正苦于以下问题:C++ unit::gender方法的具体用法?C++ unit::gender怎么用?C++ unit::gender使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unit
的用法示例。
在下文中一共展示了unit::gender方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: internal_matches_filter
//.........这里部分代码省略.........
// If this unit is a variation itself then search in the base unit's variations.
const unit_type* const type = u.variation().empty() ? &u.type() : unit_types.find(u.type().base_id());
assert(type);
for (const std::string& variation_id : utils::split(vcfg["has_variation"])) {
if (type->has_variation(variation_id)) {
match = true;
break;
}
}
if (!match) return false;
}
if (!vcfg["ability"].empty())
{
bool match = false;
for (const std::string& ability_id : utils::split(vcfg["ability"])) {
if (u.has_ability_by_id(ability_id)) {
match = true;
break;
}
}
if (!match) return false;
}
if (!vcfg["race"].empty()) {
std::vector<std::string> races = utils::split(vcfg["race"]);
if (std::find(races.begin(), races.end(), u.race()->id()) == races.end()) {
return false;
}
}
if (!vcfg["gender"].blank() && string_gender(vcfg["gender"]) != u.gender()) {
return false;
}
if (!vcfg["side"].empty() && vcfg["side"].to_int(-999) != u.side()) {
std::vector<std::string> sides = utils::split(vcfg["side"]);
const std::string u_side = std::to_string(u.side());
if (std::find(sides.begin(), sides.end(), u_side) == sides.end()) {
return false;
}
}
// handle statuses list
if (!vcfg["status"].empty()) {
bool status_found = false;
for (const std::string status : utils::split(vcfg["status"])) {
if(u.get_state(status)) {
status_found = true;
break;
}
}
if(!status_found) {
return false;
}
}
if (vcfg.has_child("has_attack")) {
const vconfig& weap_filter = vcfg.child("has_attack");
bool has_weapon = false;
for(const attack_type& a : u.attacks()) {
if(a.matches_filter(weap_filter.get_parsed_config())) {
示例2: set_displayed_unit
void tunit_preview_pane::set_displayed_unit(const unit& u)
{
// Sets the current type id for the profile button callback to use
current_type_ = u.type_id();
if(icon_type_) {
std::string mods = u.image_mods();
if(u.can_recruit()) {
mods += "~BLIT(" + unit::leader_crown() + ")";
}
for(const std::string& overlay : u.overlays()) {
mods += "~BLIT(" + overlay + ")";
}
mods += "~SCALE_INTO_SHARP(144,144)" + image_mods_;
icon_type_->set_label(u.absolute_image() + mods);
}
if(label_name_) {
std::string name;
if(!u.name().empty()) {
name = "<span size='large'>" + u.name() + "</span>" + "\n" + "<small><span color='#a69275'>" + u.type_name() + "</span></small>";
} else {
name = "<span size='large'>" + u.type_name() + "</span>\n";
}
label_name_->set_label(name);
label_name_->set_use_markup(true);
}
if(label_level_) {
std::string l_str = vgettext("Lvl $lvl", {{"lvl", std::to_string(u.level())}});
label_level_->set_label("<b>" + l_str + "</b>");
label_level_->set_use_markup(true);
}
if(icon_race_) {
icon_race_->set_label("icons/unit-groups/race_" + u.race()->id() + "_30.png");
icon_race_->set_tooltip(u.race()->name(u.gender()));
}
if(icon_alignment_) {
const std::string& alignment_name = u.alignment().to_string();
icon_alignment_->set_label("icons/alignments/alignment_" + alignment_name + "_30.png");
icon_alignment_->set_tooltip(unit_type::alignment_description(
u.alignment(),
u.gender()));
}
if(label_details_minimal_) {
std::stringstream str;
const std::string name = "<span size='large'>" + (!u.name().empty() ? u.name() : " ") + "</span>";
str << name << "\n";
str << "<span color='#a69275'>" << u.type_name() << "</span>" << "\n";
str << "Lvl " << u.level() << "\n";
str << u.alignment() << "\n";
str << utils::join(u.trait_names(), ", ") << "\n";
str << font::span_color(u.hp_color())
<< _("HP: ") << u.hitpoints() << "/" << u.max_hitpoints() << "</span>" << "\n";
str << font::span_color(u.xp_color())
<< _("XP: ") << u.experience() << "/" << u.max_experience() << "</span>";
label_details_minimal_->set_label(str.str());
label_details_minimal_->set_use_markup(true);
}
if(tree_details_) {
std::stringstream str;
str << "<small>";
str << font::span_color(u.hp_color())
<< "<b>" << _("HP: ") << "</b>" << u.hitpoints() << "/" << u.max_hitpoints() << "</span>" << " | ";
str << font::span_color(u.xp_color())
<< "<b>" << _("XP: ") << "</b>" << u.experience() << "/" << u.max_experience() << "</span>" << " | ";
str << "<b>" << _("MP: ") << "</b>"
<< u.movement_left() << "/" << u.total_movement();
str << "</small>";
tree_details_->clear();
add_name_tree_node(
tree_details_->get_root_node(),
"item",
str.str()
);
//.........这里部分代码省略.........