本文整理汇总了C++中Icon::Merge方法的典型用法代码示例。如果您正苦于以下问题:C++ Icon::Merge方法的具体用法?C++ Icon::Merge怎么用?C++ Icon::Merge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Icon
的用法示例。
在下文中一共展示了Icon::Merge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MergeStacks
void EscortDisplay::MergeStacks() const
{
if(icons.empty())
return;
set<const Sprite *> unstackable;
while(true)
{
Icon *cheapest = nullptr;
for(Icon &icon : icons)
{
if(unstackable.find(icon.sprite) == unstackable.end() && (!cheapest || *cheapest < icon))
cheapest = &icon;
}
if(icons.size() <= iconsPerColumn * columns || !cheapest)
break;
// Merge all other instances of this ship's sprite with this icon.
list<Icon>::iterator it = icons.begin();
while(it != icons.end())
{
if(&*it == cheapest || it->sprite != cheapest->sprite || it->isHere != cheapest->isHere)
{
++it;
continue;
}
cheapest->Merge(*it);
it = icons.erase(it);
}
unstackable.insert(cheapest->sprite);
}
}
示例2: MergeStacks
void EscortDisplay::MergeStacks() const
{
if(icons.empty())
return;
int maxHeight = Screen::Height() - 450;
set<const Sprite *> unstackable;
while(true)
{
Icon *cheapest = nullptr;
int height = 0;
for(Icon &icon : icons)
{
if(unstackable.find(icon.sprite) == unstackable.end() && (!cheapest || *cheapest < icon))
cheapest = &icon;
height += icon.Height();
}
if(height < maxHeight || !cheapest)
break;
// Merge all other instances of this ship's sprite with this icon.
vector<Icon>::iterator it = icons.begin();
while(it != icons.end())
{
if(&*it == cheapest || it->sprite != cheapest->sprite || it->isHere != cheapest->isHere)
{
++it;
continue;
}
cheapest->Merge(*it);
it = icons.erase(it);
}
unstackable.insert(cheapest->sprite);
}
}