Added support for a 'none' value to the video element imageType property

This commit is contained in:
Leon Styhre 2025-02-06 17:52:41 +01:00
parent 3e7436c347
commit 58b4b361ad
3 changed files with 17 additions and 6 deletions

View file

@ -562,6 +562,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
{"fontSizeDimmed", FLOAT},
{"scope", STRING},
{"entries", STRING},
{"entryLayout", STRING},
{"entrySpacing", FLOAT},
{"entrySpacingDimmed", FLOAT},
{"iconTextSpacing", FLOAT},

View file

@ -41,6 +41,7 @@ VideoComponent::VideoComponent()
, mIsPlaying {false}
, mIsActuallyPlaying {false}
, mPaused {false}
, mImageTypeNone {false}
, mMediaViewerMode {false}
, mScreensaverMode {false}
, mTargetIsMax {false}
@ -346,8 +347,8 @@ void VideoComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
}
for (std::string& type : mThemeImageTypes) {
if (std::find(supportedImageTypes.cbegin(), supportedImageTypes.cend(), type) ==
supportedImageTypes.cend()) {
if (std::find(sSupportedImageTypes.cbegin(), sSupportedImageTypes.cend(), type) ==
sSupportedImageTypes.cend()) {
LOG(LogError)
<< "VideoComponent: Invalid theme configuration, property \"imageType\" "
"for element \""
@ -357,6 +358,11 @@ void VideoComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
}
}
if (std::find(mThemeImageTypes.cbegin(), mThemeImageTypes.cend(), "none") !=
mThemeImageTypes.cend()) {
mImageTypeNone = true;
}
std::vector<std::string> sortedTypes {mThemeImageTypes};
std::stable_sort(sortedTypes.begin(), sortedTypes.end());
@ -460,7 +466,7 @@ void VideoComponent::update(int deltaTime)
if (mWindow->getGameLaunchedState())
return;
if (!mIsPlaying && (mConfig.startDelay == 0 || mStaticImagePath == "")) {
if (!mIsPlaying && (mConfig.startDelay == 0 || (mStaticImagePath == "" && !mImageTypeNone))) {
startVideoStream();
}
else if (mStartTime == 0 || SDL_GetTicks() > mStartTime) {
@ -502,6 +508,9 @@ void VideoComponent::startVideoPlayer()
mStartTime = SDL_GetTicks() + mConfig.startDelay;
setImage(mStaticImagePath);
}
else if (mConfig.showStaticImageDelay && mConfig.startDelay != 0 && mImageTypeNone) {
mStartTime = SDL_GetTicks() + mConfig.startDelay;
}
mPaused = false;
}

View file

@ -134,9 +134,9 @@ protected:
std::string mStaticImagePath;
std::string mDefaultImagePath;
static inline std::vector<std::string> supportedImageTypes {
"image", "miximage", "marquee", "screenshot", "titlescreen",
"cover", "backcover", "3dbox", "physicalmedia", "fanart"};
static inline std::vector<std::string> sSupportedImageTypes {
"image", "miximage", "marquee", "screenshot", "titlescreen", "cover",
"backcover", "3dbox", "physicalmedia", "fanart", "none"};
std::string mVideoPath;
OnIterationsDone mOnIterationsDone;
@ -144,6 +144,7 @@ protected:
std::atomic<bool> mIsPlaying;
std::atomic<bool> mIsActuallyPlaying;
std::atomic<bool> mPaused;
bool mImageTypeNone;
bool mMediaViewerMode;
bool mScreensaverMode;
bool mTargetIsMax;