mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 22:25:38 +00:00
Made GameSelectorComponent not return the same game repeatedly in a row.
This commit is contained in:
parent
ee3d32990d
commit
8e43138722
|
@ -49,6 +49,12 @@ public:
|
||||||
{
|
{
|
||||||
if (!mNeedsRefresh)
|
if (!mNeedsRefresh)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
FileData* lastGame {nullptr};
|
||||||
|
|
||||||
|
if (mGameCount == 1 && !mGames.empty())
|
||||||
|
lastGame = mGames.front();
|
||||||
|
|
||||||
mGames.clear();
|
mGames.clear();
|
||||||
mNeedsRefresh = false;
|
mNeedsRefresh = false;
|
||||||
|
|
||||||
|
@ -59,7 +65,14 @@ public:
|
||||||
for (int i = 0; i < mGameCount; ++i) {
|
for (int i = 0; i < mGameCount; ++i) {
|
||||||
if (mSystem->getRootFolder()->getGameCount().first == 0)
|
if (mSystem->getRootFolder()->getGameCount().first == 0)
|
||||||
break;
|
break;
|
||||||
FileData* randomGame {mSystem->getRandomGame(nullptr, true)};
|
FileData* randomGame {nullptr};
|
||||||
|
|
||||||
|
if (mGameCount > 1 || lastGame == nullptr ||
|
||||||
|
mSystem->getRootFolder()->getGameCount().first == 1)
|
||||||
|
randomGame = mSystem->getRandomGame(nullptr, true);
|
||||||
|
else
|
||||||
|
randomGame = mSystem->getRandomGame(lastGame, true);
|
||||||
|
|
||||||
if (randomGame != nullptr)
|
if (randomGame != nullptr)
|
||||||
mGames.emplace_back(randomGame);
|
mGames.emplace_back(randomGame);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue