本文整理汇总了C++中invlet_wrapper::size方法的典型用法代码示例。如果您正苦于以下问题:C++ invlet_wrapper::size方法的具体用法?C++ invlet_wrapper::size怎么用?C++ invlet_wrapper::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类invlet_wrapper
的用法示例。
在下文中一共展示了invlet_wrapper::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assign_empty_invlet
void inventory::assign_empty_invlet(item &it, bool force)
{
if( !get_option<bool>( "AUTO_INV_ASSIGN" ) ) {
return;
}
player *p = &(g->u);
std::set<char> cur_inv = p->allocated_invlets();
itype_id target_type = it.typeId();
for (auto iter : p->assigned_invlet) {
if (iter.second == target_type && !cur_inv.count(iter.first)) {
it.invlet = iter.first;
return;
}
}
if (cur_inv.size() < inv_chars.size()) {
for( const auto &inv_char : inv_chars ) {
if( p->assigned_invlet.count(inv_char) ) {
// don't overwrite assigned keys
continue;
}
if( cur_inv.find( inv_char ) == cur_inv.end() ) {
it.invlet = inv_char;
return;
}
}
}
if (!force) {
it.invlet = 0;
return;
}
// No free hotkey exist, re-use some of the existing ones
for( auto &elem : items ) {
item &o = elem.front();
if (o.invlet != 0) {
it.invlet = o.invlet;
o.invlet = 0;
return;
}
}
debugmsg("could not find a hotkey for %s", it.tname().c_str());
}
示例2: assign_empty_invlet
void inventory::assign_empty_invlet( item &it, const Character &p, const bool force )
{
if( !get_option<bool>( "AUTO_INV_ASSIGN" ) ) {
return;
}
invlets_bitset cur_inv = p.allocated_invlets();
itype_id target_type = it.typeId();
for( auto iter : assigned_invlet ) {
if( iter.second == target_type && !cur_inv[iter.first] ) {
it.invlet = iter.first;
return;
}
}
if( cur_inv.count() < inv_chars.size() ) {
for( const auto &inv_char : inv_chars ) {
if( assigned_invlet.count( inv_char ) ) {
// don't overwrite assigned keys
continue;
}
if( !cur_inv[inv_char] ) {
it.invlet = inv_char;
return;
}
}
}
if( !force ) {
it.invlet = 0;
return;
}
// No free hotkey exist, re-use some of the existing ones
for( auto &elem : items ) {
item &o = elem.front();
if( o.invlet != 0 ) {
it.invlet = o.invlet;
o.invlet = 0;
return;
}
}
debugmsg( "could not find a hotkey for %s", it.tname() );
}