void ViewController::goToRandomGame()
{
	unsigned int total = 0;
	for(auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); it++)
	{
		if ((*it)->getName() != "retropie")
			total += (*it)->getDisplayedGameCount();
	}
	
	// get random number in range
	int target = std::round(((double)std::rand() / (double)RAND_MAX) * total);
	
	for (auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); it++)
	{
		if ((*it)->getName() != "retropie")
		{
			if ((target - (int)(*it)->getDisplayedGameCount()) >= 0)
			{
				target -= (int)(*it)->getDisplayedGameCount();
			}
			else
			{
				goToGameList(*it);
				std::vector<FileData*> list = (*it)->getRootFolder()->getFilesRecursive(GAME, true);
				getGameListView(*it)->setCursor(list.at(target));
				return;
			}
		}
	}
}
예제 #2
0
void ViewController::goToPrevGameList()
{
	assert(mState.viewing == GAME_LIST);
	SystemData* system = getState().getSystem();
	assert(system);
	goToGameList(system->getPrev());
}
예제 #3
0
void ViewController::goToNextGameList()
{
	assert(mState.viewing == GAME_LIST);
	SystemData* system = getState().getSystem();
	assert(system);
	goToGameList(SystemManager::getInstance()->getNext(system));
}