Fixed an issue where gamelist scroll fade-in animations would continue to play after opening and closing a menu.

This commit is contained in:
Leon Styhre 2022-03-06 23:31:32 +01:00
parent 9e2c24ef79
commit 9867c3d595
6 changed files with 21 additions and 4 deletions

View file

@ -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;
}

View file

@ -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());
}

View file

@ -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<ThemeData> getTheme() const { return mTheme; }
void setTheme(const std::shared_ptr<ThemeData>& theme)
{

View file

@ -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();

View file

@ -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.

View file

@ -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; }