Added support for setting the video fade-in time via the theme configuration.

This commit is contained in:
Leon Styhre 2022-02-15 21:26:40 +01:00
parent d6c6ea839c
commit a9d1f6e307
3 changed files with 11 additions and 4 deletions

View file

@ -114,6 +114,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
{"pillarboxes", BOOLEAN},
{"scanlines", BOOLEAN},
{"delay", FLOAT},
{"fadeInTime", FLOAT},
{"scrollFadeIn", BOOLEAN},
{"opacity", FLOAT},
{"visible", BOOLEAN},

View file

@ -41,6 +41,7 @@ VideoComponent::VideoComponent()
, mRenderScanlines {false}
, mLegacyTheme {false}
, mFadeIn {1.0f}
, mFadeInTime {1000.0f}
{
// Setup the default configuration.
mConfig.showSnapshotDelay = false;
@ -294,6 +295,9 @@ void VideoComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
else if (elem->has("showSnapshotDelay"))
mConfig.showSnapshotDelay = elem->get<bool>("showSnapshotDelay");
if (properties && elem->has("fadeInTime"))
mFadeInTime = glm::clamp(elem->get<float>("fadeInTime"), 0.0f, 8.0f) * 1000.0f;
if (properties && elem->has("imageType")) {
std::string imageTypes {elem->get<std::string>("imageType")};
for (auto& character : imageTypes) {
@ -334,8 +338,9 @@ void VideoComponent::update(int deltaTime)
manageState();
// Fade in videos, the time period is a bit different between the screensaver,
// media viewer and gamelist view.
// Fade in videos, the time period is a bit different between the screensaver and media viewer.
// For the theme controlled videos in the gamelist and system views, the fade-in time is set
// via the theme configuration.
if (mScreensaverMode && mFadeIn < 1.0f) {
mFadeIn = glm::clamp(mFadeIn + (deltaTime / static_cast<float>(SCREENSAVER_FADE_IN_TIME)),
0.0f, 1.0f);
@ -345,7 +350,7 @@ void VideoComponent::update(int deltaTime)
0.0f, 1.0f);
}
else if (mFadeIn < 1.0f) {
mFadeIn = glm::clamp(mFadeIn + 0.01f, 0.0f, 1.0f);
mFadeIn = glm::clamp(mFadeIn + (deltaTime / static_cast<float>(mFadeInTime)), 0.0f, 1.0f);
}
GuiComponent::update(deltaTime);

View file

@ -145,7 +145,8 @@ protected:
bool mDrawPillarboxes;
bool mRenderScanlines;
bool mLegacyTheme;
float mFadeIn; // Used for fading in the video screensaver.
float mFadeIn;
float mFadeInTime;
Configuration mConfig;
};