本文整理汇总了C++中unit_type::alignment方法的典型用法代码示例。如果您正苦于以下问题:C++ unit_type::alignment方法的具体用法?C++ unit_type::alignment怎么用?C++ unit_type::alignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unit_type
的用法示例。
在下文中一共展示了unit_type::alignment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vgettext
void tunit_preview_pane::set_displayed_type(const unit_type& type)
{
// Sets the current type id for the profile button callback to use
current_type_ = type.id();
if(icon_type_) {
std::string mods;
if(resources::controller) {
mods = "~RC(" + type.flag_rgb() + ">" +
team::get_side_color_index(resources::controller->current_side())
+ ")";
}
mods += "~SCALE_INTO_SHARP(144,144)" + image_mods_;
icon_type_->set_label((type.icon().empty() ? type.image() : type.icon()) + mods);
}
if(label_name_) {
label_name_->set_label("<big>" + type.type_name() + "</big>");
label_name_->set_use_markup(true);
}
if(label_level_) {
std::string l_str = vgettext("Lvl $lvl", {{"lvl", std::to_string(type.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_" + type.race_id() + "_30.png");
icon_race_->set_tooltip(type.race()->name(type.genders().front()));
}
if(icon_alignment_) {
const std::string& alignment_name = type.alignment().to_string();
icon_alignment_->set_label("icons/alignments/alignment_" + alignment_name + "_30.png");
icon_alignment_->set_tooltip(unit_type::alignment_description(
type.alignment(),
type.genders().front()));
}
if(tree_details_) {
std::stringstream str;
str << "<small>";
str << "<span color='#21e100'>"
<< "<b>" << _("HP: ") << "</b>" << type.hitpoints() << "</span>" << " | ";
str << "<span color='#00a0e1'>"
<< "<b>" << _("XP: ") << "</b>" << type.experience_needed() << "</span>" << " | ";
str << "<b>" << _("MP: ") << "</b>"
<< type.movement();
str << "</small>";
tree_details_->clear();
add_name_tree_node(
tree_details_->get_root_node(),
"item",
str.str()
);
// Print trait details
{
ttree_view_node* header_node = nullptr;
for(const auto& tr : type.possible_traits()) {
t_string name = tr[type.genders().front() == unit_race::FEMALE ? "female_name" : "male_name"];
if (tr["availability"] != "musthave" || name.empty()) {
continue;
}
if (header_node == nullptr) {
header_node = &add_name_tree_node(
tree_details_->get_root_node(),
"header",
"<b>" + _("Traits") + "</b>"
);
}
add_name_tree_node(
*header_node,
"item",
name
);
}
}
// Print ability details
if(!type.abilities().empty()) {
auto& header_node = add_name_tree_node(
tree_details_->get_root_node(),
"header",
"<b>" + _("Abilities") + "</b>"
);
//.........这里部分代码省略.........