mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-26 16:15:39 +00:00
Changed ScreenSaver to use TextComponent instead of using Font facilities directly
This commit is contained in:
parent
5776d37d54
commit
8ff6f50635
|
@ -54,6 +54,7 @@ Screensaver::Screensaver()
|
||||||
void Screensaver::startScreensaver(bool generateMediaList)
|
void Screensaver::startScreensaver(bool generateMediaList)
|
||||||
{
|
{
|
||||||
ViewController::getInstance()->pauseViewVideos();
|
ViewController::getInstance()->pauseViewVideos();
|
||||||
|
mGameOverlay = std::make_unique<TextComponent>("", Font::get(FONT_SIZE_SMALL), 0xFFFFFFFF);
|
||||||
|
|
||||||
mScreensaverType = Settings::getInstance()->getString("ScreensaverType");
|
mScreensaverType = Settings::getInstance()->getString("ScreensaverType");
|
||||||
// In case there is an invalid entry in the es_settings.xml file.
|
// In case there is an invalid entry in the es_settings.xml file.
|
||||||
|
@ -67,13 +68,6 @@ void Screensaver::startScreensaver(bool generateMediaList)
|
||||||
mFallbackScreensaver = false;
|
mFallbackScreensaver = false;
|
||||||
mOpacity = 0.0f;
|
mOpacity = 0.0f;
|
||||||
|
|
||||||
// Keep a reference to the default fonts, so they don't keep getting destroyed/recreated.
|
|
||||||
if (mGameOverlayFont.empty()) {
|
|
||||||
mGameOverlayFont.push_back(Font::get(FONT_SIZE_SMALL));
|
|
||||||
mGameOverlayFont.push_back(Font::get(FONT_SIZE_MEDIUM));
|
|
||||||
mGameOverlayFont.push_back(Font::get(FONT_SIZE_LARGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set mPreviousGame which will be used to avoid showing the same game again during
|
// Set mPreviousGame which will be used to avoid showing the same game again during
|
||||||
// the random selection.
|
// the random selection.
|
||||||
if ((mScreensaverType == "slideshow" || mScreensaverType == "video") && mCurrentGame != nullptr)
|
if ((mScreensaverType == "slideshow" || mScreensaverType == "video") && mCurrentGame != nullptr)
|
||||||
|
@ -196,6 +190,7 @@ void Screensaver::stopScreensaver()
|
||||||
{
|
{
|
||||||
mImageScreensaver.reset();
|
mImageScreensaver.reset();
|
||||||
mVideoScreensaver.reset();
|
mVideoScreensaver.reset();
|
||||||
|
mGameOverlay.reset();
|
||||||
|
|
||||||
mScreensaverActive = false;
|
mScreensaverActive = false;
|
||||||
mDimValue = 1.0f;
|
mDimValue = 1.0f;
|
||||||
|
@ -203,9 +198,6 @@ void Screensaver::stopScreensaver()
|
||||||
mTextFadeIn = 0;
|
mTextFadeIn = 0;
|
||||||
mSaturationAmount = 1.0f;
|
mSaturationAmount = 1.0f;
|
||||||
|
|
||||||
if (mGameOverlay)
|
|
||||||
mGameOverlay.reset();
|
|
||||||
|
|
||||||
ViewController::getInstance()->startViewVideos();
|
ViewController::getInstance()->startViewVideos();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,8 +290,7 @@ void Screensaver::renderScreensaver()
|
||||||
if (Settings::getInstance()->getBool("ScreensaverSlideshowScanlines"))
|
if (Settings::getInstance()->getBool("ScreensaverSlideshowScanlines"))
|
||||||
mRenderer->shaderPostprocessing(Renderer::Shader::SCANLINES);
|
mRenderer->shaderPostprocessing(Renderer::Shader::SCANLINES);
|
||||||
if (Settings::getInstance()->getBool("ScreensaverSlideshowGameInfo") &&
|
if (Settings::getInstance()->getBool("ScreensaverSlideshowGameInfo") &&
|
||||||
!Settings::getInstance()->getBool("ScreensaverSlideshowCustomImages") &&
|
!Settings::getInstance()->getBool("ScreensaverSlideshowCustomImages")) {
|
||||||
mGameOverlay) {
|
|
||||||
mRenderer->setMatrix(mRenderer->getIdentity());
|
mRenderer->setMatrix(mRenderer->getIdentity());
|
||||||
if (mGameOverlayRectangleCoords.size() == 4) {
|
if (mGameOverlayRectangleCoords.size() == 4) {
|
||||||
mRenderer->drawRect(
|
mRenderer->drawRect(
|
||||||
|
@ -311,7 +302,7 @@ void Screensaver::renderScreensaver()
|
||||||
|
|
||||||
mGameOverlay.get()->setColor(0xFFFFFF00 | mTextFadeIn);
|
mGameOverlay.get()->setColor(0xFFFFFF00 | mTextFadeIn);
|
||||||
if (mTextFadeIn > 50)
|
if (mTextFadeIn > 50)
|
||||||
mGameOverlayFont.at(0)->renderTextCache(mGameOverlay.get());
|
mGameOverlay->render(trans);
|
||||||
if (mTextFadeIn < 255)
|
if (mTextFadeIn < 255)
|
||||||
mTextFadeIn = glm::clamp(mTextFadeIn + 2 + mTextFadeIn / 6, 0, 255);
|
mTextFadeIn = glm::clamp(mTextFadeIn + 2 + mTextFadeIn / 6, 0, 255);
|
||||||
}
|
}
|
||||||
|
@ -340,7 +331,7 @@ void Screensaver::renderScreensaver()
|
||||||
if (shaders != 0)
|
if (shaders != 0)
|
||||||
mRenderer->shaderPostprocessing(shaders, videoParameters);
|
mRenderer->shaderPostprocessing(shaders, videoParameters);
|
||||||
|
|
||||||
if (Settings::getInstance()->getBool("ScreensaverVideoGameInfo") && mGameOverlay) {
|
if (Settings::getInstance()->getBool("ScreensaverVideoGameInfo")) {
|
||||||
mRenderer->setMatrix(mRenderer->getIdentity());
|
mRenderer->setMatrix(mRenderer->getIdentity());
|
||||||
if (mGameOverlayRectangleCoords.size() == 4) {
|
if (mGameOverlayRectangleCoords.size() == 4) {
|
||||||
mRenderer->drawRect(
|
mRenderer->drawRect(
|
||||||
|
@ -352,7 +343,7 @@ void Screensaver::renderScreensaver()
|
||||||
|
|
||||||
mGameOverlay.get()->setColor(0xFFFFFF00 | mTextFadeIn);
|
mGameOverlay.get()->setColor(0xFFFFFF00 | mTextFadeIn);
|
||||||
if (mTextFadeIn > 50)
|
if (mTextFadeIn > 50)
|
||||||
mGameOverlayFont.at(0)->renderTextCache(mGameOverlay.get());
|
mGameOverlay->render(trans);
|
||||||
if (mTextFadeIn < 255)
|
if (mTextFadeIn < 255)
|
||||||
mTextFadeIn = glm::clamp(mTextFadeIn + 2 + mTextFadeIn / 6, 0, 255);
|
mTextFadeIn = glm::clamp(mTextFadeIn + 2 + mTextFadeIn / 6, 0, 255);
|
||||||
}
|
}
|
||||||
|
@ -689,8 +680,8 @@ void Screensaver::generateOverlayInfo()
|
||||||
if (mGameName == "" || mSystemName == "")
|
if (mGameName == "" || mSystemName == "")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float posX {mRenderer->getScreenWidth() * 0.023f};
|
const float posX {mRenderer->getScreenWidth() * 0.023f};
|
||||||
float posY {mRenderer->getScreenHeight() * 0.02f};
|
const float posY {mRenderer->getScreenHeight() * 0.02f};
|
||||||
|
|
||||||
const bool favoritesOnly {
|
const bool favoritesOnly {
|
||||||
(mScreensaverType == "video" &&
|
(mScreensaverType == "video" &&
|
||||||
|
@ -707,28 +698,17 @@ void Screensaver::generateOverlayInfo()
|
||||||
const std::string systemName {Utils::String::toUpper(mSystemName)};
|
const std::string systemName {Utils::String::toUpper(mSystemName)};
|
||||||
const std::string overlayText {gameName + "\n" + systemName};
|
const std::string overlayText {gameName + "\n" + systemName};
|
||||||
|
|
||||||
mGameOverlay = std::unique_ptr<TextCache>(
|
mGameOverlay->setText(overlayText);
|
||||||
mGameOverlayFont.at(0)->buildTextCache(overlayText, posX, posY, 0xFFFFFFFF));
|
mGameOverlay->setPosition(posX, posY);
|
||||||
|
|
||||||
float textSizeX {0.0f};
|
// Setting the Y size to zero makes the text area expand vertically as needed.
|
||||||
float textSizeY {mGameOverlayFont[0].get()->sizeText(overlayText).y};
|
mGameOverlay->setSize(mGameOverlay->getSize().x, 0.0f);
|
||||||
|
|
||||||
// There is a weird issue with sizeText() where the X size value is returned
|
const float marginX {mRenderer->getScreenWidth() * 0.01f};
|
||||||
// as too large if there are two rows in a string and the second row is longer
|
|
||||||
// than the first row. Possibly it's the newline character that is somehow
|
|
||||||
// injected in the size calculation. Regardless, this workaround is working
|
|
||||||
// fine for the time being.
|
|
||||||
if (mGameOverlayFont[0].get()->sizeText(gameName).x >
|
|
||||||
mGameOverlayFont[0].get()->sizeText(systemName).x)
|
|
||||||
textSizeX = mGameOverlayFont[0].get()->sizeText(gameName).x;
|
|
||||||
else
|
|
||||||
textSizeX = mGameOverlayFont[0].get()->sizeText(systemName).x;
|
|
||||||
|
|
||||||
float marginX {mRenderer->getScreenWidth() * 0.01f};
|
|
||||||
|
|
||||||
mGameOverlayRectangleCoords.clear();
|
mGameOverlayRectangleCoords.clear();
|
||||||
mGameOverlayRectangleCoords.push_back(posX - marginX);
|
mGameOverlayRectangleCoords.push_back(posX - marginX);
|
||||||
mGameOverlayRectangleCoords.push_back(posY);
|
mGameOverlayRectangleCoords.push_back(posY);
|
||||||
mGameOverlayRectangleCoords.push_back(textSizeX + marginX * 2.0f);
|
mGameOverlayRectangleCoords.push_back(mGameOverlay->getSize().x + marginX * 2.0f);
|
||||||
mGameOverlayRectangleCoords.push_back(textSizeY);
|
mGameOverlayRectangleCoords.push_back(mGameOverlay->getSize().y);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
|
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "components/ImageComponent.h"
|
#include "components/ImageComponent.h"
|
||||||
|
#include "components/TextComponent.h"
|
||||||
#include "components/VideoComponent.h"
|
#include "components/VideoComponent.h"
|
||||||
#include "resources/Font.h"
|
|
||||||
|
|
||||||
class Screensaver : public Window::Screensaver
|
class Screensaver : public Window::Screensaver
|
||||||
{
|
{
|
||||||
|
@ -54,6 +54,8 @@ private:
|
||||||
std::vector<std::string> mCustomFilesInventory;
|
std::vector<std::string> mCustomFilesInventory;
|
||||||
std::unique_ptr<ImageComponent> mImageScreensaver;
|
std::unique_ptr<ImageComponent> mImageScreensaver;
|
||||||
std::unique_ptr<VideoComponent> mVideoScreensaver;
|
std::unique_ptr<VideoComponent> mVideoScreensaver;
|
||||||
|
std::unique_ptr<TextComponent> mGameOverlay;
|
||||||
|
std::vector<float> mGameOverlayRectangleCoords;
|
||||||
|
|
||||||
FileData* mCurrentGame;
|
FileData* mCurrentGame;
|
||||||
FileData* mPreviousGame;
|
FileData* mPreviousGame;
|
||||||
|
@ -73,10 +75,6 @@ private:
|
||||||
unsigned char mRectangleFadeIn;
|
unsigned char mRectangleFadeIn;
|
||||||
unsigned char mTextFadeIn;
|
unsigned char mTextFadeIn;
|
||||||
float mSaturationAmount;
|
float mSaturationAmount;
|
||||||
|
|
||||||
std::unique_ptr<TextCache> mGameOverlay;
|
|
||||||
std::vector<std::shared_ptr<Font>> mGameOverlayFont;
|
|
||||||
std::vector<float> mGameOverlayRectangleCoords;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_APP_SCREENSAVER_H
|
#endif // ES_APP_SCREENSAVER_H
|
||||||
|
|
Loading…
Reference in a new issue