本文整理汇总了C++中item::info方法的典型用法代码示例。如果您正苦于以下问题:C++ item::info方法的具体用法?C++ item::info怎么用?C++ item::info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类item
的用法示例。
在下文中一共展示了item::info方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: iteminfo_test
void iteminfo_test( const item &i, const iteminfo_query &q, const std::string &reference )
{
g->u.empty_traits();
std::vector<iteminfo> info_v;
std::string info = i.info( info_v, &q, 1 );
CHECK( info == reference );
}
示例2: select
virtual void select(int entnum, uimenu *menu) {
const int starty = 3;
const int startx = menu->w_width - menu->pad_right;
itype *ity = item_controller->find_template(standard_itype_ids[entnum]);
std::string padding = std::string(menu->pad_right - 1, ' ');
for(int i = 0; i < lastlen + starty + 1; i++ ) {
mvwprintw(menu->window, 1 + i, startx, "%s", padding.c_str() );
}
if ( ity != NULL ) {
tmp.make(item_controller->find_template(standard_itype_ids[entnum]));
tmp.bday = g->turn;
if (tmp.is_tool()) {
tmp.charges = dynamic_cast<it_tool *>(tmp.type)->max_charges;
} else if (tmp.is_ammo()) {
tmp.charges = 100;
} else if (tmp.is_gun()) {
tmp.charges = 0;
} else if (tmp.is_gunmod() && (tmp.has_flag("MODE_AUX") ||
tmp.typeId() == "spare_mag")) {
tmp.charges = 0;
} else {
tmp.charges = -1;
}
if( tmp.is_stationary() ) {
tmp.note = SNIPPET.assign( (dynamic_cast<it_stationary *>(tmp.type))->category );
}
std::vector<std::string> desc = foldstring(tmp.info(true), menu->pad_right - 1);
int dsize = desc.size();
if ( dsize > menu->w_height - 5 ) {
dsize = menu->w_height - 5;
}
lastlen = dsize;
std::string header = string_format("#%d: %s%s",
entnum,
standard_itype_ids[entnum].c_str(),
( incontainer ? " (contained)" : "" )
);
mvwprintz(menu->window, 1, startx + ( menu->pad_right - 1 - header.size() ) / 2, c_cyan, "%s",
header.c_str()
);
for(int i = 0; i < desc.size(); i++ ) {
mvwprintw(menu->window, starty + i, startx, "%s", desc[i].c_str() );
}
mvwprintz(menu->window, menu->w_height - 3, startx, c_green, "%s", msg.c_str());
msg = padding;
mvwprintw(menu->window, menu->w_height - 2, startx, "[/] find, [f] container, [q]uit");
}
}
示例3: lcmatch
std::vector<const recipe *> recipe_subset::search( const std::string &txt,
const search_type key ) const
{
std::vector<const recipe *> res;
std::copy_if( recipes.begin(), recipes.end(), std::back_inserter( res ), [&]( const recipe * r ) {
if( !*r ) {
return false;
}
switch( key ) {
case search_type::name:
return lcmatch( r->result_name(), txt );
case search_type::skill:
return lcmatch( r->required_skills_string( nullptr ), txt ) ||
lcmatch( r->skill_used->name(), txt );
case search_type::primary_skill:
return lcmatch( r->skill_used->name(), txt );
case search_type::component:
return search_reqs( r->requirements().get_components(), txt );
case search_type::tool:
return search_reqs( r->requirements().get_tools(), txt );
case search_type::quality:
return search_reqs( r->requirements().get_qualities(), txt );
case search_type::quality_result: {
const auto &quals = item::find_type( r->result() )->qualities;
return std::any_of( quals.begin(), quals.end(), [&]( const std::pair<quality_id, int> &e ) {
return lcmatch( e.first->name, txt );
} );
}
case search_type::description_result: {
const item result = r->create_result();
return lcmatch( remove_color_tags( result.info( true ) ), txt );
}
default:
return false;
}
} );
return res;
}