mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 17:45:38 +00:00
Improved the random game selection functionality in GameSelectorComponent.
This commit is contained in:
parent
f195ba72a2
commit
da3fb9a825
|
@ -63,9 +63,12 @@ public:
|
||||||
Settings::getInstance()->getBool("ForceKid"))};
|
Settings::getInstance()->getBool("ForceKid"))};
|
||||||
|
|
||||||
if (mGameSelection == GameSelection::RANDOM) {
|
if (mGameSelection == GameSelection::RANDOM) {
|
||||||
for (int i = 0; i < mGameCount; ++i) {
|
int tries {8};
|
||||||
|
for (int i {0}; i < mGameCount; ++i) {
|
||||||
if (mSystem->getRootFolder()->getGameCount().first == 0)
|
if (mSystem->getRootFolder()->getGameCount().first == 0)
|
||||||
break;
|
break;
|
||||||
|
if (mSystem->getRootFolder()->getGameCount().first == mGames.size())
|
||||||
|
break;
|
||||||
FileData* randomGame {nullptr};
|
FileData* randomGame {nullptr};
|
||||||
|
|
||||||
if (mGameCount > 1 || lastGame == nullptr ||
|
if (mGameCount > 1 || lastGame == nullptr ||
|
||||||
|
@ -74,6 +77,14 @@ public:
|
||||||
else
|
else
|
||||||
randomGame = mSystem->getRandomGame(lastGame, true);
|
randomGame = mSystem->getRandomGame(lastGame, true);
|
||||||
|
|
||||||
|
if (std::find(mGames.begin(), mGames.end(), randomGame) != mGames.end()) {
|
||||||
|
if (tries > 0) {
|
||||||
|
--i;
|
||||||
|
--tries;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (randomGame != nullptr)
|
if (randomGame != nullptr)
|
||||||
mGames.emplace_back(randomGame);
|
mGames.emplace_back(randomGame);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue