mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-16 20:15:38 +00:00
Lottie animations are now paused during view transitions.
This commit is contained in:
parent
f803e23fd2
commit
c06dea5d2d
|
@ -85,6 +85,12 @@ void GamelistView::onShow()
|
|||
updateInfoPanel();
|
||||
}
|
||||
|
||||
void GamelistView::onTransition()
|
||||
{
|
||||
for (auto& animation : mLottieAnimComponents)
|
||||
animation->setPauseAnimation(true);
|
||||
}
|
||||
|
||||
void GamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
||||
{
|
||||
auto themeSets = ThemeData::getThemeSets();
|
||||
|
|
|
@ -23,6 +23,7 @@ public:
|
|||
// Called when a FileData* is added, has its metadata changed, or is removed.
|
||||
void onFileChanged(FileData* file, bool reloadGamelist) override;
|
||||
void onShow() override;
|
||||
void onTransition() override;
|
||||
|
||||
void preloadGamelist() { updateInfoPanel(); }
|
||||
void launch(FileData* game) override { ViewController::getInstance()->triggerGameLaunch(game); }
|
||||
|
|
|
@ -330,6 +330,9 @@ void ViewController::goToSystemView(SystemData* system, bool playTransition)
|
|||
mPreviousView = nullptr;
|
||||
}
|
||||
|
||||
if (mCurrentView != nullptr)
|
||||
mCurrentView->onTransition();
|
||||
|
||||
mPreviousView = mCurrentView;
|
||||
|
||||
if (system->isGroupedCustomCollection())
|
||||
|
@ -415,6 +418,9 @@ void ViewController::goToGamelist(SystemData* system)
|
|||
bool wrapLastToFirst = false;
|
||||
bool slideTransitions = false;
|
||||
|
||||
if (mCurrentView != nullptr)
|
||||
mCurrentView->onTransition();
|
||||
|
||||
if (Settings::getInstance()->getString("TransitionStyle") == "slide")
|
||||
slideTransitions = true;
|
||||
|
||||
|
|
|
@ -238,6 +238,7 @@ public:
|
|||
|
||||
virtual void onShow();
|
||||
virtual void onHide();
|
||||
virtual void onTransition() {}
|
||||
|
||||
// System view and gamelist view video controls.
|
||||
virtual void startViewVideos() {}
|
||||
|
|
|
@ -36,6 +36,7 @@ LottieComponent::LottieComponent()
|
|||
, mSkippedFrames {0}
|
||||
, mHoldFrame {false}
|
||||
, mPause {false}
|
||||
, mExternalPause {false}
|
||||
, mAlternate {false}
|
||||
, mKeepAspectRatio {true}
|
||||
{
|
||||
|
@ -190,6 +191,7 @@ void LottieComponent::setAnimation(const std::string& path)
|
|||
|
||||
void LottieComponent::resetFileAnimation()
|
||||
{
|
||||
mExternalPause = false;
|
||||
mTimeAccumulator = 0;
|
||||
mFrameNum = mStartDirection == "reverse" ? mTotalFrames - 1 : 0;
|
||||
|
||||
|
@ -336,7 +338,7 @@ void LottieComponent::render(const glm::mat4& parentTrans)
|
|||
glm::mat4 trans {parentTrans * getTransform()};
|
||||
|
||||
// This is necessary as there may otherwise be no texture to render when paused.
|
||||
if (mPause && mTexture->getSize().x == 0.0f) {
|
||||
if ((mExternalPause || mPause) && mTexture->getSize().x == 0.0f) {
|
||||
mTexture->initFromPixels(&mPictureRGBA.at(0), static_cast<size_t>(mSize.x),
|
||||
static_cast<size_t>(mSize.y));
|
||||
}
|
||||
|
@ -352,7 +354,7 @@ void LottieComponent::render(const glm::mat4& parentTrans)
|
|||
}
|
||||
|
||||
// Don't render any new frames if paused or if a menu is open (unless invalidating background).
|
||||
if (!mPause && doRender) {
|
||||
if ((!mPause && !mExternalPause) && doRender) {
|
||||
if ((mDirection == "normal" && mFrameNum >= mTotalFrames) ||
|
||||
(mDirection == "reverse" && mFrameNum > mTotalFrames)) {
|
||||
if (DEBUG_ANIMATION) {
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
{
|
||||
mMaxCacheSize = static_cast<size_t>(glm::clamp(value, 0, 1024) * 1024 * 1024);
|
||||
}
|
||||
void setPauseAnimation(bool state) { mExternalPause = state; }
|
||||
|
||||
void resetFileAnimation() override;
|
||||
void onSizeChanged() override;
|
||||
|
@ -42,8 +43,9 @@ public:
|
|||
const std::string& element,
|
||||
unsigned int properties) override;
|
||||
|
||||
private:
|
||||
void update(int deltaTime) override;
|
||||
|
||||
private:
|
||||
void render(const glm::mat4& parentTrans) override;
|
||||
|
||||
std::shared_ptr<TextureResource> mTexture;
|
||||
|
@ -76,6 +78,7 @@ private:
|
|||
|
||||
bool mHoldFrame;
|
||||
bool mPause;
|
||||
bool mExternalPause;
|
||||
bool mAlternate;
|
||||
bool mKeepAspectRatio;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue