mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
Changed the screensaver to never show the same game again until all games have been cycled through
This commit is contained in:
parent
b669280412
commit
912c8bb75a
|
@ -82,7 +82,9 @@ void Screensaver::startScreensaver(bool generateMediaList)
|
|||
if (mScreensaverType == "slideshow") {
|
||||
if (generateMediaList) {
|
||||
mImageFiles.clear();
|
||||
mFilesInventory.clear();
|
||||
mImageCustomFiles.clear();
|
||||
mCustomFilesInventory.clear();
|
||||
}
|
||||
|
||||
mMediaSwapTime = Settings::getInstance()->getInt("ScreensaverSwapImageTimeout");
|
||||
|
@ -93,6 +95,11 @@ void Screensaver::startScreensaver(bool generateMediaList)
|
|||
generateCustomImageList();
|
||||
pickRandomCustomImage(path);
|
||||
|
||||
// We've cycled through all games, so start from the beginning again.
|
||||
if (mImageCustomFiles.size() == 0 && mCustomFilesInventory.size() > 0)
|
||||
mImageCustomFiles.insert(mImageCustomFiles.begin(), mCustomFilesInventory.begin(),
|
||||
mCustomFilesInventory.end());
|
||||
|
||||
if (mImageCustomFiles.size() > 0)
|
||||
mHasMediaFiles = true;
|
||||
// Custom images are not tied to the game list.
|
||||
|
@ -104,6 +111,10 @@ void Screensaver::startScreensaver(bool generateMediaList)
|
|||
pickRandomImage(path);
|
||||
}
|
||||
|
||||
// We've cycled through all games, so start from the beginning again.
|
||||
if (mImageFiles.size() == 0 && mFilesInventory.size() > 0)
|
||||
mImageFiles.insert(mImageFiles.begin(), mFilesInventory.begin(), mFilesInventory.end());
|
||||
|
||||
if (mImageFiles.size() > 0)
|
||||
mHasMediaFiles = true;
|
||||
|
||||
|
@ -135,8 +146,10 @@ void Screensaver::startScreensaver(bool generateMediaList)
|
|||
return;
|
||||
}
|
||||
else if (!mVideoScreensaver && (mScreensaverType == "video")) {
|
||||
if (generateMediaList)
|
||||
if (generateMediaList) {
|
||||
mVideoFiles.clear();
|
||||
mFilesInventory.clear();
|
||||
}
|
||||
|
||||
mMediaSwapTime = Settings::getInstance()->getInt("ScreensaverSwapVideoTimeout");
|
||||
|
||||
|
@ -145,6 +158,10 @@ void Screensaver::startScreensaver(bool generateMediaList)
|
|||
generateVideoList();
|
||||
pickRandomVideo(path);
|
||||
|
||||
// We've cycled through all games, so start from the beginning again.
|
||||
if (mVideoFiles.size() == 0 && mFilesInventory.size() > 0)
|
||||
mVideoFiles.insert(mVideoFiles.begin(), mFilesInventory.begin(), mFilesInventory.end());
|
||||
|
||||
if (mVideoFiles.size() > 0)
|
||||
mHasMediaFiles = true;
|
||||
|
||||
|
@ -276,95 +293,92 @@ void Screensaver::renderScreensaver()
|
|||
}
|
||||
}
|
||||
|
||||
if (isScreensaverActive()) {
|
||||
if (mScreensaverType == "slideshow") {
|
||||
if (mHasMediaFiles) {
|
||||
if (Settings::getInstance()->getBool("ScreensaverSlideshowScanlines"))
|
||||
mRenderer->shaderPostprocessing(Renderer::Shader::SCANLINES);
|
||||
if (Settings::getInstance()->getBool("ScreensaverSlideshowGameInfo") &&
|
||||
mGameOverlay) {
|
||||
mRenderer->setMatrix(mRenderer->getIdentity());
|
||||
if (mGameOverlayRectangleCoords.size() == 4) {
|
||||
mRenderer->drawRect(
|
||||
mGameOverlayRectangleCoords[0], mGameOverlayRectangleCoords[1],
|
||||
mGameOverlayRectangleCoords[2], mGameOverlayRectangleCoords[3],
|
||||
0x00000000 | mRectangleFadeIn, 0x00000000 | mRectangleFadeIn);
|
||||
}
|
||||
mRectangleFadeIn =
|
||||
glm::clamp(mRectangleFadeIn + 6 + mRectangleFadeIn / 20, 0, 170);
|
||||
|
||||
mGameOverlay.get()->setColor(0xFFFFFF00 | mTextFadeIn);
|
||||
if (mTextFadeIn > 50)
|
||||
mGameOverlayFont.at(0)->renderTextCache(mGameOverlay.get());
|
||||
if (mTextFadeIn < 255)
|
||||
mTextFadeIn = glm::clamp(mTextFadeIn + 2 + mTextFadeIn / 6, 0, 255);
|
||||
if (mScreensaverType == "slideshow") {
|
||||
if (mHasMediaFiles) {
|
||||
if (Settings::getInstance()->getBool("ScreensaverSlideshowScanlines"))
|
||||
mRenderer->shaderPostprocessing(Renderer::Shader::SCANLINES);
|
||||
if (Settings::getInstance()->getBool("ScreensaverSlideshowGameInfo") &&
|
||||
!Settings::getInstance()->getBool("ScreensaverSlideshowCustomImages") &&
|
||||
mGameOverlay) {
|
||||
mRenderer->setMatrix(mRenderer->getIdentity());
|
||||
if (mGameOverlayRectangleCoords.size() == 4) {
|
||||
mRenderer->drawRect(
|
||||
mGameOverlayRectangleCoords[0], mGameOverlayRectangleCoords[1],
|
||||
mGameOverlayRectangleCoords[2], mGameOverlayRectangleCoords[3],
|
||||
0x00000000 | mRectangleFadeIn, 0x00000000 | mRectangleFadeIn);
|
||||
}
|
||||
}
|
||||
else {
|
||||
mFallbackScreensaver = true;
|
||||
mRectangleFadeIn = glm::clamp(mRectangleFadeIn + 6 + mRectangleFadeIn / 20, 0, 170);
|
||||
|
||||
mGameOverlay.get()->setColor(0xFFFFFF00 | mTextFadeIn);
|
||||
if (mTextFadeIn > 50)
|
||||
mGameOverlayFont.at(0)->renderTextCache(mGameOverlay.get());
|
||||
if (mTextFadeIn < 255)
|
||||
mTextFadeIn = glm::clamp(mTextFadeIn + 2 + mTextFadeIn / 6, 0, 255);
|
||||
}
|
||||
}
|
||||
else if (mScreensaverType == "video") {
|
||||
if (mHasMediaFiles) {
|
||||
Renderer::postProcessingParams videoParameters;
|
||||
unsigned int shaders {0};
|
||||
if (Settings::getInstance()->getBool("ScreensaverVideoScanlines"))
|
||||
shaders = Renderer::Shader::SCANLINES;
|
||||
if (Settings::getInstance()->getBool("ScreensaverVideoBlur")) {
|
||||
if (mRenderer->getScreenRotation() == 90 ||
|
||||
mRenderer->getScreenRotation() == 270)
|
||||
shaders |= Renderer::Shader::BLUR_VERTICAL;
|
||||
else
|
||||
shaders |= Renderer::Shader::BLUR_HORIZONTAL;
|
||||
else {
|
||||
mFallbackScreensaver = true;
|
||||
}
|
||||
}
|
||||
else if (mScreensaverType == "video") {
|
||||
if (mHasMediaFiles) {
|
||||
Renderer::postProcessingParams videoParameters;
|
||||
unsigned int shaders {0};
|
||||
if (Settings::getInstance()->getBool("ScreensaverVideoScanlines"))
|
||||
shaders = Renderer::Shader::SCANLINES;
|
||||
if (Settings::getInstance()->getBool("ScreensaverVideoBlur")) {
|
||||
if (mRenderer->getScreenRotation() == 90 || mRenderer->getScreenRotation() == 270)
|
||||
shaders |= Renderer::Shader::BLUR_VERTICAL;
|
||||
else
|
||||
shaders |= Renderer::Shader::BLUR_HORIZONTAL;
|
||||
}
|
||||
|
||||
// We run two passes to make the blur smoother.
|
||||
videoParameters.blurPasses = 2;
|
||||
videoParameters.blurStrength = 1.35f;
|
||||
|
||||
if (shaders != 0)
|
||||
mRenderer->shaderPostprocessing(shaders, videoParameters);
|
||||
|
||||
if (Settings::getInstance()->getBool("ScreensaverVideoGameInfo") && mGameOverlay) {
|
||||
mRenderer->setMatrix(mRenderer->getIdentity());
|
||||
if (mGameOverlayRectangleCoords.size() == 4) {
|
||||
mRenderer->drawRect(
|
||||
mGameOverlayRectangleCoords[0], mGameOverlayRectangleCoords[1],
|
||||
mGameOverlayRectangleCoords[2], mGameOverlayRectangleCoords[3],
|
||||
0x00000000 | mRectangleFadeIn, 0x00000000 | mRectangleFadeIn);
|
||||
}
|
||||
mRectangleFadeIn = glm::clamp(mRectangleFadeIn + 6 + mRectangleFadeIn / 20, 0, 170);
|
||||
|
||||
// We run two passes to make the blur smoother.
|
||||
videoParameters.blurPasses = 2;
|
||||
videoParameters.blurStrength = 1.35f;
|
||||
|
||||
if (shaders != 0)
|
||||
mRenderer->shaderPostprocessing(shaders, videoParameters);
|
||||
|
||||
if (Settings::getInstance()->getBool("ScreensaverVideoGameInfo") && mGameOverlay) {
|
||||
mRenderer->setMatrix(mRenderer->getIdentity());
|
||||
if (mGameOverlayRectangleCoords.size() == 4) {
|
||||
mRenderer->drawRect(
|
||||
mGameOverlayRectangleCoords[0], mGameOverlayRectangleCoords[1],
|
||||
mGameOverlayRectangleCoords[2], mGameOverlayRectangleCoords[3],
|
||||
0x00000000 | mRectangleFadeIn, 0x00000000 | mRectangleFadeIn);
|
||||
}
|
||||
mRectangleFadeIn =
|
||||
glm::clamp(mRectangleFadeIn + 6 + mRectangleFadeIn / 20, 0, 170);
|
||||
|
||||
mGameOverlay.get()->setColor(0xFFFFFF00 | mTextFadeIn);
|
||||
if (mTextFadeIn > 50)
|
||||
mGameOverlayFont.at(0)->renderTextCache(mGameOverlay.get());
|
||||
if (mTextFadeIn < 255)
|
||||
mTextFadeIn = glm::clamp(mTextFadeIn + 2 + mTextFadeIn / 6, 0, 255);
|
||||
}
|
||||
}
|
||||
else {
|
||||
mFallbackScreensaver = true;
|
||||
mGameOverlay.get()->setColor(0xFFFFFF00 | mTextFadeIn);
|
||||
if (mTextFadeIn > 50)
|
||||
mGameOverlayFont.at(0)->renderTextCache(mGameOverlay.get());
|
||||
if (mTextFadeIn < 255)
|
||||
mTextFadeIn = glm::clamp(mTextFadeIn + 2 + mTextFadeIn / 6, 0, 255);
|
||||
}
|
||||
}
|
||||
if (mFallbackScreensaver || mScreensaverType == "dim") {
|
||||
Renderer::postProcessingParams dimParameters;
|
||||
dimParameters.dimming = mDimValue;
|
||||
dimParameters.saturation = mSaturationAmount;
|
||||
mRenderer->shaderPostprocessing(Renderer::Shader::CORE, dimParameters);
|
||||
if (mDimValue > 0.4)
|
||||
mDimValue = glm::clamp(mDimValue - 0.021f, 0.4f, 1.0f);
|
||||
if (mSaturationAmount > 0.0)
|
||||
mSaturationAmount = glm::clamp(mSaturationAmount - 0.035f, 0.0f, 1.0f);
|
||||
}
|
||||
else if (mScreensaverType == "black") {
|
||||
Renderer::postProcessingParams blackParameters;
|
||||
blackParameters.dimming = mDimValue;
|
||||
mRenderer->shaderPostprocessing(Renderer::Shader::CORE, blackParameters);
|
||||
if (mDimValue > 0.0)
|
||||
mDimValue = glm::clamp(mDimValue - 0.045f, 0.0f, 1.0f);
|
||||
else {
|
||||
mFallbackScreensaver = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (mFallbackScreensaver || mScreensaverType == "dim") {
|
||||
Renderer::postProcessingParams dimParameters;
|
||||
dimParameters.dimming = mDimValue;
|
||||
dimParameters.saturation = mSaturationAmount;
|
||||
mRenderer->shaderPostprocessing(Renderer::Shader::CORE, dimParameters);
|
||||
if (mDimValue > 0.4)
|
||||
mDimValue = glm::clamp(mDimValue - 0.021f, 0.4f, 1.0f);
|
||||
if (mSaturationAmount > 0.0)
|
||||
mSaturationAmount = glm::clamp(mSaturationAmount - 0.035f, 0.0f, 1.0f);
|
||||
}
|
||||
else if (mScreensaverType == "black") {
|
||||
Renderer::postProcessingParams blackParameters;
|
||||
blackParameters.dimming = mDimValue;
|
||||
mRenderer->shaderPostprocessing(Renderer::Shader::CORE, blackParameters);
|
||||
if (mDimValue > 0.0)
|
||||
mDimValue = glm::clamp(mDimValue - 0.045f, 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
void Screensaver::update(int deltaTime)
|
||||
|
@ -417,6 +431,8 @@ void Screensaver::generateImageList()
|
|||
mImageFiles.push_back((*it2));
|
||||
}
|
||||
}
|
||||
|
||||
mFilesInventory.insert(mFilesInventory.begin(), mImageFiles.begin(), mImageFiles.end());
|
||||
}
|
||||
|
||||
void Screensaver::generateVideoList()
|
||||
|
@ -442,6 +458,8 @@ void Screensaver::generateVideoList()
|
|||
mVideoFiles.push_back((*it2));
|
||||
}
|
||||
}
|
||||
|
||||
mFilesInventory.insert(mFilesInventory.begin(), mVideoFiles.begin(), mVideoFiles.end());
|
||||
}
|
||||
|
||||
void Screensaver::generateCustomImageList()
|
||||
|
@ -469,6 +487,9 @@ void Screensaver::generateCustomImageList()
|
|||
else {
|
||||
LOG(LogWarning) << "Custom screensaver image directory '" << imageDir << "' does not exist";
|
||||
}
|
||||
|
||||
mCustomFilesInventory.insert(mCustomFilesInventory.begin(), mImageCustomFiles.begin(),
|
||||
mImageCustomFiles.end());
|
||||
}
|
||||
|
||||
void Screensaver::pickRandomImage(std::string& path)
|
||||
|
@ -485,6 +506,7 @@ void Screensaver::pickRandomImage(std::string& path)
|
|||
mGameName = mImageFiles.front()->getName();
|
||||
mSystemName = mImageFiles.front()->getSystem()->getFullName();
|
||||
mCurrentGame = mImageFiles.front();
|
||||
mImageFiles.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -503,6 +525,10 @@ void Screensaver::pickRandomImage(std::string& path)
|
|||
mGameName = mImageFiles.at(index)->getName();
|
||||
mSystemName = mImageFiles.at(index)->getSystem()->getFullName();
|
||||
mCurrentGame = mImageFiles.at(index);
|
||||
|
||||
// Don't display the same image again until we've cycled through all entries.
|
||||
auto it = mImageFiles.begin() + index;
|
||||
mImageFiles.erase(it);
|
||||
}
|
||||
|
||||
void Screensaver::pickRandomVideo(std::string& path)
|
||||
|
@ -519,6 +545,7 @@ void Screensaver::pickRandomVideo(std::string& path)
|
|||
mGameName = mVideoFiles.front()->getName();
|
||||
mSystemName = mVideoFiles.front()->getSystem()->getFullName();
|
||||
mCurrentGame = mVideoFiles.front();
|
||||
mVideoFiles.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -537,6 +564,10 @@ void Screensaver::pickRandomVideo(std::string& path)
|
|||
mGameName = mVideoFiles.at(index)->getName();
|
||||
mSystemName = mVideoFiles.at(index)->getSystem()->getFullName();
|
||||
mCurrentGame = mVideoFiles.at(index);
|
||||
|
||||
// Don't play the same video again until we've cycled through all entries.
|
||||
auto it = mVideoFiles.begin() + index;
|
||||
mVideoFiles.erase(it);
|
||||
}
|
||||
|
||||
void Screensaver::pickRandomCustomImage(std::string& path)
|
||||
|
@ -547,6 +578,7 @@ void Screensaver::pickRandomCustomImage(std::string& path)
|
|||
if (mImageCustomFiles.size() == 1) {
|
||||
mPreviousCustomImage = mImageCustomFiles.front();
|
||||
path = mImageCustomFiles.front();
|
||||
mImageCustomFiles.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -565,6 +597,10 @@ void Screensaver::pickRandomCustomImage(std::string& path)
|
|||
mPreviousCustomImage = path;
|
||||
mGameName = "";
|
||||
mSystemName = "";
|
||||
|
||||
// Don't display the same image again until we've cycled through all entries.
|
||||
auto it = mImageCustomFiles.begin() + index;
|
||||
mImageCustomFiles.erase(it);
|
||||
}
|
||||
|
||||
void Screensaver::generateOverlayInfo()
|
||||
|
|
|
@ -49,7 +49,9 @@ private:
|
|||
|
||||
std::vector<FileData*> mImageFiles;
|
||||
std::vector<FileData*> mVideoFiles;
|
||||
std::vector<FileData*> mFilesInventory;
|
||||
std::vector<std::string> mImageCustomFiles;
|
||||
std::vector<std::string> mCustomFilesInventory;
|
||||
std::unique_ptr<ImageComponent> mImageScreensaver;
|
||||
std::unique_ptr<VideoComponent> mVideoScreensaver;
|
||||
|
||||
|
|
|
@ -810,6 +810,7 @@ void Window::startScreensaver(bool onTimer)
|
|||
setAllowTextScrolling(false);
|
||||
setAllowFileAnimation(false);
|
||||
mScreensaver->startScreensaver(true);
|
||||
mScreensaver->renderScreensaver();
|
||||
mRenderScreensaver = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue