Some video code cleanup

This commit is contained in:
Leon Styhre 2023-07-30 20:12:23 +02:00
parent 9fa5274792
commit 0267a9db00
3 changed files with 9 additions and 13 deletions

View file

@ -48,8 +48,7 @@ VideoComponent::VideoComponent()
, mFadeInTime {1000.0f}
{
// Setup default configuration.
mConfig.showSnapshotDelay = false;
mConfig.showSnapshotNoVideo = false;
mConfig.showStaticImageDelay = false;
mConfig.startDelay = 1500;
}
@ -223,10 +222,8 @@ void VideoComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
mConfig.startDelay =
static_cast<unsigned int>(glm::clamp(elem->get<float>("delay"), 0.0f, 15.0f) * 1000.0f);
mConfig.showSnapshotNoVideo = true;
if (mConfig.startDelay != 0)
mConfig.showSnapshotDelay = true;
mConfig.showStaticImageDelay = true;
if (properties && elem->has("fadeInTime"))
mFadeInTime = glm::clamp(elem->get<float>("fadeInTime"), 0.0f, 8.0f) * 1000.0f;
@ -344,7 +341,7 @@ void VideoComponent::update(int deltaTime)
return;
// Hack to prevent the video from starting to play if the static image was shown when paused.
if (mConfig.showSnapshotDelay && mPaused)
if (mConfig.showStaticImageDelay && mPaused)
mStartTime = SDL_GetTicks() + mConfig.startDelay;
if (mWindow->getGameLaunchedState())
@ -386,7 +383,7 @@ void VideoComponent::startVideoPlayer()
if (mIsPlaying)
stopVideoPlayer();
if (mConfig.showSnapshotDelay && mConfig.startDelay != 0 && mStaticImagePath != "") {
if (mConfig.showStaticImageDelay && mConfig.startDelay != 0 && mStaticImagePath != "") {
mStartTime = SDL_GetTicks() + mConfig.startDelay;
setImage(mStaticImagePath);
}
@ -394,9 +391,9 @@ void VideoComponent::startVideoPlayer()
mPaused = false;
}
void VideoComponent::renderSnapshot(const glm::mat4& parentTrans)
void VideoComponent::renderStaticImage(const glm::mat4& parentTrans)
{
if (mHasVideo && (!mConfig.showSnapshotDelay || mConfig.startDelay == 0))
if (mHasVideo && (!mConfig.showStaticImageDelay || mConfig.startDelay == 0))
return;
if (mStaticImagePath != "") {

View file

@ -23,8 +23,7 @@ class VideoComponent : public GuiComponent
// Structure that groups together the configuration of the video component.
struct Configuration {
unsigned startDelay;
bool showSnapshotNoVideo;
bool showSnapshotDelay;
bool showStaticImageDelay;
std::string defaultVideoPath;
std::string staticVideoPath;
};
@ -93,7 +92,7 @@ public:
protected:
virtual void startVideoStream() {}
void renderSnapshot(const glm::mat4& parentTrans);
void renderStaticImage(const glm::mat4& parentTrans);
ImageComponent mStaticImage;

View file

@ -265,7 +265,7 @@ void VideoFFmpegComponent::render(const glm::mat4& parentTrans)
}
else {
if (mVisible)
VideoComponent::renderSnapshot(parentTrans);
VideoComponent::renderStaticImage(parentTrans);
}
}