本文整理汇总了C++中utils::signed_percent方法的典型用法代码示例。如果您正苦于以下问题:C++ utils::signed_percent方法的具体用法?C++ utils::signed_percent怎么用?C++ utils::signed_percent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils
的用法示例。
在下文中一共展示了utils::signed_percent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generate_report
report generate_report(TYPE type,
const team &viewing_team, int current_side, int playing_side,
const map_location& loc, const map_location& mouseover,
const std::set<std::string> &observers,
const config& level, bool show_everything)
{
unit_map& units = *resources::units;
gamemap& map = *resources::game_map;
std::vector<team>& teams = *resources::teams;
const unit *u = NULL;
if ((int(type) >= int(UNIT_REPORTS_BEGIN) && int(type) < int(UNIT_REPORTS_END)) || type == POSITION){
u = get_visible_unit(loc, viewing_team, show_everything);
if (!u && type != POSITION) {
return report();
}
}
std::ostringstream str;
std::ostringstream tooltip;
using utils::signed_percent;
using font::span_color;
switch(type) {
case UNIT_NAME:
// str << font::SMALL_TEXT << u->name();
str << u->name();
tooltip << _("Name: ") << u->name();
return report(str.str(), "", tooltip.str());
case UNIT_TYPE: {
if (!u->packed()) {
str << "<245,230,193>" << u->type_name();
} else {
str << "<245,230,193>" << u->packee_type()->type_name();
str << "[" << u->type_name() << "]";
}
if (game_config::tiny_gui) {
str << "(" << hero::adaptability_str2(ftofxp12(u->adaptability_[u->arms()])) << ")";
}
tooltip << _("Type: ")
<< u->type_name();
const std::string help_page = "unit_" + u->type_id();
return report(str.str(), "", tooltip.str(), help_page);
}
case UNIT_RACE: {
str << "<166,146,117>" << u->race()->name(u->gender());
const std::string help_page = "..race_" + u->race()->id();
return report(str.str(), "", tooltip.str(), help_page);
}
case UNIT_SIDE: {
std::string flag_icon = teams[u->side() - 1].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;
}
image::locator flag_icon_img(flag_icon, mods);
return report("", flag_icon_img, teams[u->side() - 1].current_player());
}
case UNIT_LEVEL: {
str << u->level();
tooltip << _("Level: ")
<< "<b>" << u->level() << "</b>\n";
const std::vector<std::string>& adv_to = u->advances_to();
if(adv_to.empty()) {
tooltip << _("No advancement");
} else {
tooltip << _("Advances to:") << "\n"
<< "<b>\t" << utils::join(adv_to, "\n\t") << "</b>";
}
return report(str.str(), "", tooltip.str());
}
case UNIT_AMLA: {
report res;
typedef std::pair<std::string, std::string> pair_string;
foreach(const pair_string& ps, u->amla_icons()) {
res.add_image(ps.first,ps.second);
}
return(res);
}
case UNIT_TRAITS: {
report res;
const std::vector<t_string>& traits = u->trait_names();
unsigned int nb = traits.size();
for(unsigned int i = 0; i < nb; ++i) {
str << traits[i];
//.........这里部分代码省略.........