Added options to the video and slideshow screensavers to only include favorite games

This commit is contained in:
Leon Styhre 2023-07-01 15:57:29 +02:00
parent 67b84434db
commit 30ca0497aa
3 changed files with 47 additions and 1 deletions

View file

@ -433,6 +433,9 @@ void Screensaver::update(int deltaTime)
void Screensaver::generateImageList()
{
const bool favoritesOnly {
Settings::getInstance()->getBool("ScreensaverSlideshowOnlyFavorites")};
for (auto it = SystemData::sSystemVector.cbegin(); // Line break.
it != SystemData::sSystemVector.cend(); ++it) {
// We only want nodes from game systems that are not collections.
@ -445,6 +448,8 @@ void Screensaver::generateImageList()
if (UIModeController::getInstance()->isUIModeKid() &&
(*it2)->metadata.get("kidgame") != "true")
continue;
if (favoritesOnly && (*it2)->metadata.get("favorite") != "true")
continue;
std::string imagePath {(*it2)->getImagePath()};
if (imagePath != "")
mImageFiles.push_back((*it2));
@ -454,6 +459,8 @@ void Screensaver::generateImageList()
void Screensaver::generateVideoList()
{
const bool favoritesOnly {Settings::getInstance()->getBool("ScreensaverVideoOnlyFavorites")};
for (auto it = SystemData::sSystemVector.cbegin(); // Line break.
it != SystemData::sSystemVector.cend(); ++it) {
// We only want nodes from game systems that are not collections.
@ -466,6 +473,8 @@ void Screensaver::generateVideoList()
if (UIModeController::getInstance()->isUIModeKid() &&
(*it2)->metadata.get("kidgame") != "true")
continue;
if (favoritesOnly && (*it2)->metadata.get("favorite") != "true")
continue;
std::string videoPath {(*it2)->getVideoPath()};
if (videoPath != "")
mVideoFiles.push_back((*it2));
@ -604,8 +613,15 @@ void Screensaver::generateOverlayInfo()
float posX {mRenderer->getScreenWidth() * 0.023f};
float posY {mRenderer->getScreenHeight() * 0.02f};
const bool favoritesOnly {
(mScreensaverType == "video" &&
Settings::getInstance()->getBool("ScreensaverVideoOnlyFavorites")) ||
(mScreensaverType == "slideshow" &&
Settings::getInstance()->getBool("ScreensaverSlideshowOnlyFavorites"))};
std::string favoriteChar;
if (mCurrentGame && mCurrentGame->getFavorite())
// Don't add the favorites character if only displaying favorite games.
if (!favoritesOnly && mCurrentGame && mCurrentGame->getFavorite())
favoriteChar.append(" ").append(ViewController::FAVORITE_CHAR);
const std::string gameName {Utils::String::toUpper(mGameName) + favoriteChar};

View file

@ -121,6 +121,20 @@ void GuiScreensaverOptions::openSlideshowScreensaverOptions()
}
});
// Only include favorite games.
auto screensaverSlideshowOnlyFavorites = std::make_shared<SwitchComponent>();
screensaverSlideshowOnlyFavorites->setState(
Settings::getInstance()->getBool("ScreensaverSlideshowOnlyFavorites"));
s->addWithLabel("ONLY INCLUDE FAVORITE GAMES", screensaverSlideshowOnlyFavorites);
s->addSaveFunc([screensaverSlideshowOnlyFavorites, s] {
if (screensaverSlideshowOnlyFavorites->getState() !=
Settings::getInstance()->getBool("ScreensaverSlideshowOnlyFavorites")) {
Settings::getInstance()->setBool("ScreensaverSlideshowOnlyFavorites",
screensaverSlideshowOnlyFavorites->getState());
s->setNeedsSaving();
}
});
// Stretch images to screen resolution.
auto screensaverStretchImages = std::make_shared<SwitchComponent>();
screensaverStretchImages->setState(
@ -231,6 +245,20 @@ void GuiScreensaverOptions::openVideoScreensaverOptions()
}
});
// Only include favorite games.
auto screensaverVideoOnlyFavorites = std::make_shared<SwitchComponent>();
screensaverVideoOnlyFavorites->setState(
Settings::getInstance()->getBool("ScreensaverVideoOnlyFavorites"));
s->addWithLabel("ONLY INCLUDE FAVORITE GAMES", screensaverVideoOnlyFavorites);
s->addSaveFunc([screensaverVideoOnlyFavorites, s] {
if (screensaverVideoOnlyFavorites->getState() !=
Settings::getInstance()->getBool("ScreensaverVideoOnlyFavorites")) {
Settings::getInstance()->setBool("ScreensaverVideoOnlyFavorites",
screensaverVideoOnlyFavorites->getState());
s->setNeedsSaving();
}
});
// Stretch videos to screen resolution.
auto screensaverStretchVideos = std::make_shared<SwitchComponent>();
screensaverStretchVideos->setState(

View file

@ -190,6 +190,7 @@ void Settings::setDefaults()
// UI settings -> screensaver settings -> slideshow screensaver settings.
mIntMap["ScreensaverSwapImageTimeout"] = {10000, 10000};
mBoolMap["ScreensaverSlideshowOnlyFavorites"] = {false, false};
mBoolMap["ScreensaverStretchImages"] = {false, false};
mBoolMap["ScreensaverSlideshowGameInfo"] = {true, true};
mBoolMap["ScreensaverSlideshowScanlines"] = {true, true};
@ -200,6 +201,7 @@ void Settings::setDefaults()
// UI settings -> screensaver settings -> video screensaver settings.
mIntMap["ScreensaverSwapVideoTimeout"] = {0, 0};
mBoolMap["ScreensaverVideoOnlyFavorites"] = {false, false};
mBoolMap["ScreensaverStretchVideos"] = {false, false};
mBoolMap["ScreensaverVideoGameInfo"] = {true, true};
#if defined(RASPBERRY_PI)