本文整理汇总了C++中ArticleDefinitionList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ArticleDefinitionList::size方法的具体用法?C++ ArticleDefinitionList::size怎么用?C++ ArticleDefinitionList::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArticleDefinitionList
的用法示例。
在下文中一共展示了ArticleDefinitionList::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getArticleIndex
/**
* Gets the index of the selected article_id in the visible list.
* If the id is not found, returns -1.
* @param save Pointer to saved game.
* @param rule Pointer to ruleset.
* @param article_id Article id to find.
* @returns Index of the given article id in the internal list, -1 if not found.
*/
size_t Ufopaedia::getArticleIndex(SavedGame *save, Ruleset *rule, std::string &article_id)
{
std::string UC_ID = article_id + "_UC";
ArticleDefinitionList articles = getAvailableArticles(save, rule);
for (size_t it=0; it<articles.size(); ++it)
{
for (std::vector<std::string>::iterator j = articles[it]->requires.begin(); j != articles[it]->requires.end(); ++j)
{
if (article_id == *j)
{
article_id = articles[it]->id;
return it;
}
}
if (articles[it]->id == article_id)
{
return it;
}
if (articles[it]->id == UC_ID)
{
article_id = UC_ID;
return it;
}
}
return -1;
}
示例2: getArticleIndex
/**
* Gets the index of the selected article_id in the visible list.
* If the id is not found, returns -1.
* @param article_id Article id to find.
* @returns Index of the given article id in the internal list, -1 if not found.
*/
size_t Ufopaedia::getArticleIndex(Game *game, const std::string &article_id)
{
ArticleDefinitionList articles = getAvailableArticles(game);
for (size_t it=0; it<articles.size(); ++it)
{
if (articles[it]->id == article_id)
{
return it;
}
}
return -1;
}
示例3: prev
/**
* Open the previous article in the list. Loops to the last.
* @param game Pointer to actual game.
*/
void Ufopaedia::prev(Game *game)
{
ArticleDefinitionList articles = getAvailableArticles(game->getSavedGame(), game->getRuleset());
if (_current_index == 0)
{
// goto last
_current_index = articles.size() - 1;
}
else
{
_current_index--;
}
game->popState();
game->pushState(createArticleState(articles[_current_index]));
}
示例4: next
/**
* Open the next article in the list. Loops to the first.
* @param game Pointer to actual game.
*/
void Ufopaedia::next(Game *game)
{
ArticleDefinitionList articles = getAvailableArticles(game->getSavedGame(), game->getRuleset());
if (_current_index >= articles.size() - 1)
{
// goto first
_current_index = 0;
}
else
{
_current_index++;
}
game->popState();
game->pushState(createArticleState(articles[_current_index]));
}