mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
Added an allowDuplicates property to the gameselector element.
This commit is contained in:
parent
94498bb706
commit
cc896bb626
|
@ -470,7 +470,8 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"zIndex", FLOAT}}},
|
{"zIndex", FLOAT}}},
|
||||||
{"gameselector",
|
{"gameselector",
|
||||||
{{"selection", STRING},
|
{{"selection", STRING},
|
||||||
{"gameCount", UNSIGNED_INTEGER}}},
|
{"gameCount", UNSIGNED_INTEGER},
|
||||||
|
{"allowDuplicates", BOOLEAN}}},
|
||||||
{"helpsystem",
|
{"helpsystem",
|
||||||
{{"pos", NORMALIZED_PAIR},
|
{{"pos", NORMALIZED_PAIR},
|
||||||
{"origin", NORMALIZED_PAIR},
|
{"origin", NORMALIZED_PAIR},
|
||||||
|
|
|
@ -22,6 +22,7 @@ public:
|
||||||
, mGameSelection {GameSelection::RANDOM}
|
, mGameSelection {GameSelection::RANDOM}
|
||||||
, mNeedsRefresh {false}
|
, mNeedsRefresh {false}
|
||||||
, mGameCount {1}
|
, mGameCount {1}
|
||||||
|
, mAllowDuplicates {false}
|
||||||
{
|
{
|
||||||
mSystem->getRootFolder()->setUpdateListCallback([&]() { mNeedsRefresh = true; });
|
mSystem->getRootFolder()->setUpdateListCallback([&]() { mNeedsRefresh = true; });
|
||||||
}
|
}
|
||||||
|
@ -64,11 +65,12 @@ public:
|
||||||
Settings::getInstance()->getBool("ForceKid"))};
|
Settings::getInstance()->getBool("ForceKid"))};
|
||||||
|
|
||||||
if (mGameSelection == GameSelection::RANDOM) {
|
if (mGameSelection == GameSelection::RANDOM) {
|
||||||
int tries {8};
|
int tries {mSystem->getRootFolder()->getGameCount().first < 6 ? 12 : 8};
|
||||||
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;
|
||||||
if (mSystem->getRootFolder()->getGameCount().first == mGames.size())
|
if (!mAllowDuplicates &&
|
||||||
|
mSystem->getRootFolder()->getGameCount().first == mGames.size())
|
||||||
break;
|
break;
|
||||||
FileData* randomGame {nullptr};
|
FileData* randomGame {nullptr};
|
||||||
|
|
||||||
|
@ -83,6 +85,10 @@ public:
|
||||||
--i;
|
--i;
|
||||||
--tries;
|
--tries;
|
||||||
}
|
}
|
||||||
|
else if (mAllowDuplicates && randomGame != nullptr) {
|
||||||
|
mGames.emplace_back(randomGame);
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,6 +166,9 @@ public:
|
||||||
|
|
||||||
if (elem->has("gameCount"))
|
if (elem->has("gameCount"))
|
||||||
mGameCount = glm::clamp(static_cast<int>(elem->get<unsigned int>("gameCount")), 1, 30);
|
mGameCount = glm::clamp(static_cast<int>(elem->get<unsigned int>("gameCount")), 1, 30);
|
||||||
|
|
||||||
|
if (elem->has("allowDuplicates"))
|
||||||
|
mAllowDuplicates = elem->get<bool>("allowDuplicates");
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -170,6 +179,7 @@ private:
|
||||||
GameSelection mGameSelection;
|
GameSelection mGameSelection;
|
||||||
bool mNeedsRefresh;
|
bool mNeedsRefresh;
|
||||||
int mGameCount;
|
int mGameCount;
|
||||||
|
bool mAllowDuplicates;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_CORE_COMPONENTS_GAME_SELECTOR_COMPONENT_H
|
#endif // ES_CORE_COMPONENTS_GAME_SELECTOR_COMPONENT_H
|
||||||
|
|
Loading…
Reference in a new issue