From 9867c3d595a6b024c9e2d69d6a54a08d8ea65cc8 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 6 Mar 2022 23:31:32 +0100 Subject: [PATCH] Fixed an issue where gamelist scroll fade-in animations would continue to play after opening and closing a menu. --- es-app/src/views/GamelistBase.cpp | 1 + es-app/src/views/GamelistLegacy.h | 2 ++ es-app/src/views/GamelistView.h | 12 ++++++++++++ es-app/src/views/ViewController.cpp | 1 + es-core/src/GuiComponent.cpp | 8 ++++---- es-core/src/GuiComponent.h | 1 + 6 files changed, 21 insertions(+), 4 deletions(-) diff --git a/es-app/src/views/GamelistBase.cpp b/es-app/src/views/GamelistBase.cpp index 6d53aba9e..93bca1fe6 100644 --- a/es-app/src/views/GamelistBase.cpp +++ b/es-app/src/views/GamelistBase.cpp @@ -458,6 +458,7 @@ bool GamelistBase::input(InputConfig* config, Input input) ViewController::getInstance()->cancelViewTransitions(); stopListScrolling(); pauseViewVideos(); + stopScrollFadeIn(); mWindow->pushGui(new GuiGamelistOptions(this->mRoot->getSystem())); return true; } diff --git a/es-app/src/views/GamelistLegacy.h b/es-app/src/views/GamelistLegacy.h index 889b9c356..d7e321b21 100644 --- a/es-app/src/views/GamelistLegacy.h +++ b/es-app/src/views/GamelistLegacy.h @@ -70,6 +70,7 @@ void GamelistView::legacyPopulateFields() mList.getPosition().y + mSize.y * 0.2125f); mImageComponents.back()->setMaxSize(mSize.x * (0.50f - 2.0f * padding), mSize.y * 0.4f); mImageComponents.back()->setDefaultZIndex(30.0f); + mImageComponents.back()->setScrollFadeIn(true); addChild(mImageComponents.back().get()); if (mViewStyle == ViewController::VIDEO) { @@ -81,6 +82,7 @@ void GamelistView::legacyPopulateFields() mList.getPosition().y + mSize.y * 0.2125f); mVideoComponents.back()->setSize(mSize.x * (0.5f - 2.0f * padding), mSize.y * 0.4f); mVideoComponents.back()->setDefaultZIndex(30.0f); + mVideoComponents.back()->setScrollFadeIn(true); mVideoComponents.back()->setVisible(false); addChild(mVideoComponents.back().get()); } diff --git a/es-app/src/views/GamelistView.h b/es-app/src/views/GamelistView.h index f47fc0bd8..4bc6ec5a6 100644 --- a/es-app/src/views/GamelistView.h +++ b/es-app/src/views/GamelistView.h @@ -64,6 +64,18 @@ public: video->muteVideoPlayer(); } + void stopScrollFadeIn() override + { + for (auto& image : mImageComponents) { + if (image->getScrollFadeIn()) + image->finishAnimation(0); + } + for (auto& video : mVideoComponents) { + if (video->getScrollFadeIn()) + video->finishAnimation(0); + } + } + const std::shared_ptr getTheme() const { return mTheme; } void setTheme(const std::shared_ptr& theme) { diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index a1541ebe8..e6517b866 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -831,6 +831,7 @@ bool ViewController::input(InputConfig* config, Input input) mCurrentView->stopListScrolling(); // Pause all videos as they would otherwise continue to play beneath the menu. mCurrentView->pauseViewVideos(); + mCurrentView->stopScrollFadeIn(); // Finally, if the camera is currently moving, reset its position. cancelViewTransitions(); diff --git a/es-core/src/GuiComponent.cpp b/es-core/src/GuiComponent.cpp index e0eff08cc..42b24a565 100644 --- a/es-core/src/GuiComponent.cpp +++ b/es-core/src/GuiComponent.cpp @@ -273,10 +273,10 @@ const bool GuiComponent::cancelAnimation(unsigned char slot) const bool GuiComponent::finishAnimation(unsigned char slot) { assert(slot < MAX_ANIMATIONS); - AnimationController* anim = mAnimationMap[slot]; + AnimationController* anim {mAnimationMap[slot]}; if (anim) { // Skip to animation's end. - const bool done = anim->update(anim->getAnimation()->getDuration() - anim->getTime()); + const bool done {anim->update(anim->getAnimation()->getDuration() - anim->getTime())}; if (done) { mAnimationMap[slot] = nullptr; delete anim; // Will also call finishedCallback. @@ -291,9 +291,9 @@ const bool GuiComponent::finishAnimation(unsigned char slot) const bool GuiComponent::advanceAnimation(unsigned char slot, unsigned int time) { assert(slot < MAX_ANIMATIONS); - AnimationController* anim = mAnimationMap[slot]; + AnimationController* anim {mAnimationMap[slot]}; if (anim) { - bool done = anim->update(time); + bool done {anim->update(time)}; if (done) { mAnimationMap[slot] = nullptr; delete anim; // Will also call finishedCallback. diff --git a/es-core/src/GuiComponent.h b/es-core/src/GuiComponent.h index bc2392703..4af2ae4be 100644 --- a/es-core/src/GuiComponent.h +++ b/es-core/src/GuiComponent.h @@ -189,6 +189,7 @@ public: void stopAllAnimations(); void cancelAllAnimations(); + virtual void stopScrollFadeIn() {} virtual bool isListScrolling() { return false; } virtual void stopListScrolling() {} virtual const float getOpacity() const { return mOpacity; }