本文整理汇总了C++中unit::type_name方法的典型用法代码示例。如果您正苦于以下问题:C++ unit::type_name方法的具体用法?C++ unit::type_name怎么用?C++ unit::type_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unit
的用法示例。
在下文中一共展示了unit::type_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static std::string format_stats(const unit& u)
{
const std::string name = "<span size='large'>" + (!u.name().empty() ? u.name() : " ") + "</span>";
std::string traits;
BOOST_FOREACH(const std::string& trait, u.get_traits_list()) {
traits += (traits.empty() ? "" : ", ") + trait;
}
if (traits.empty()) {
traits = " ";
}
std::stringstream str;
str << name << "\n";
str << "<small>";
str << "<span color='#f5e6c1'>" << u.type_name() << "</span>" << "\n";
str << "Lvl " << u.level() << "\n";
str << u.alignment() << "\n";
str << traits << "\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>" << "\n";
str << "</small>" << "\n";
return str.str();
}
示例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()
);
//.........这里部分代码省略.........