本文整理汇总了C++中unit::overlays方法的典型用法代码示例。如果您正苦于以下问题:C++ unit::overlays方法的具体用法?C++ unit::overlays怎么用?C++ unit::overlays使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unit
的用法示例。
在下文中一共展示了unit::overlays方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static std::string get_image_mods(const unit& u)
{
std::string res
= "~RC(" + u.team_color() + ">" + team::get_side_color_index(u.side()) + ")";
if (u.can_recruit()) {
res += "~BLIT(" + unit::leader_crown() + ")";
}
BOOST_FOREACH(const std::string& overlay, u.overlays()) {
res += "~BLIT(" + overlay + ")";
}
return res;
}
示例2: redraw_unit
//.........这里部分代码省略.........
if (preferences::show_enemy_orb() && !u.incapacitated())
orb_img = &enemy_orb;
else
orb_img = nullptr;
} else {
if (preferences::show_allied_orb())
orb_img = &ally_orb;
else orb_img = nullptr;
}
} else {
if (preferences::show_moved_orb())
orb_img = &moved_orb;
else orb_img = nullptr;
if(playing_team == viewing_team && !u.user_end_turn()) {
if (movement_left == total_movement) {
if (preferences::show_unmoved_orb())
orb_img = &unmoved_orb;
else orb_img = nullptr;
} else if ( dc.unit_can_move(u) ) {
if (preferences::show_partial_orb())
orb_img = &partmoved_orb;
else orb_img = nullptr;
}
}
}
if (orb_img != nullptr) {
surface orb(image::get_image(*orb_img,image::SCALED_TO_ZOOM));
disp.drawing_buffer_add(display::LAYER_UNIT_BAR,
loc, xsrc + xoff, ysrc + yoff + adjusted_params.y, orb);
}
double unit_energy = 0.0;
if(max_hitpoints > 0) {
unit_energy = double(hitpoints)/double(max_hitpoints);
}
const int bar_shift = static_cast<int>(-5*zoom_factor);
const int hp_bar_height = static_cast<int>(max_hitpoints * u.hp_bar_scaling());
const fixed_t bar_alpha = (loc == mouse_hex || loc == sel_hex) ? ftofxp(1.0): ftofxp(0.8);
draw_bar(*energy_file, xsrc+xoff+bar_shift, ysrc+yoff+adjusted_params.y,
loc, hp_bar_height, unit_energy,hp_color, bar_alpha);
if(experience > 0 && can_advance) {
const double filled = double(experience)/double(max_experience);
const int xp_bar_height = static_cast<int>(max_experience * u.xp_bar_scaling() / std::max<int>(u.level(),1));
draw_bar(*energy_file, xsrc+xoff, ysrc+yoff+adjusted_params.y,
loc, xp_bar_height, filled, xp_color, bar_alpha);
}
if (can_recruit) {
surface crown(image::get_image(u.leader_crown(),image::SCALED_TO_ZOOM));
if(!crown.null()) {
//if(bar_alpha != ftofxp(1.0)) {
// crown = adjust_surface_alpha(crown, bar_alpha);
//}
disp.drawing_buffer_add(display::LAYER_UNIT_BAR,
loc, xsrc+xoff, ysrc+yoff+adjusted_params.y, crown);
}
}
for(std::vector<std::string>::const_iterator ov = u.overlays().begin(); ov != u.overlays().end(); ++ov) {
#ifdef SDL_GPU
const sdl::timage ov_img(image::get_texture(*ov, image::SCALED_TO_ZOOM));
if(!ov_img.null()) {
disp.drawing_buffer_add(display::LAYER_UNIT_BAR,
loc, xsrc, ysrc +adjusted_params.y, ov_img);
}
#else
const surface ov_img(image::get_image(*ov, image::SCALED_TO_ZOOM));
if(ov_img != nullptr) {
disp.drawing_buffer_add(display::LAYER_UNIT_BAR,
loc, xsrc+xoff, ysrc+yoff+adjusted_params.y, ov_img);
}
#endif
}
}
// Smooth unit movements from terrain of different elevation.
// Do this separately from above so that the health bar doesn't go up and down.
const t_translation::t_terrain terrain_dst = map.get_terrain(dst);
const terrain_type& terrain_dst_info = map.get_terrain_info(terrain_dst);
int height_adjust_unit = static_cast<int>((terrain_info.unit_height_adjust() * (1.0 - adjusted_params.offset) +
terrain_dst_info.unit_height_adjust() * adjusted_params.offset) *
zoom_factor);
if (is_flying && height_adjust_unit < 0) {
height_adjust_unit = 0;
}
params.y -= height_adjust_unit - height_adjust;
params.halo_y -= height_adjust_unit - height_adjust;
ac.anim_->redraw(params, halo_man);
ac.refreshing_ = false;
}
示例3: 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()
);
//.........这里部分代码省略.........