mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-12-01 18:45:39 +00:00
Fixed a reverse scrolling issue in CarouselComponent.
This commit is contained in:
parent
d1cbbad8ee
commit
03f8e020c3
|
@ -32,6 +32,7 @@ namespace
|
||||||
SystemView::SystemView()
|
SystemView::SystemView()
|
||||||
: mCamOffset {0.0f}
|
: mCamOffset {0.0f}
|
||||||
, mFadeOpacity {0.0f}
|
, mFadeOpacity {0.0f}
|
||||||
|
, mPreviousScrollVelocity {0}
|
||||||
, mUpdatedGameCount {false}
|
, mUpdatedGameCount {false}
|
||||||
, mViewNeedsReload {true}
|
, mViewNeedsReload {true}
|
||||||
, mLegacyMode {false}
|
, mLegacyMode {false}
|
||||||
|
@ -240,6 +241,20 @@ void SystemView::onCursorChanged(const CursorState& /*state*/)
|
||||||
if (fabs(target - posMax - startPos - scrollVelocity) < dist)
|
if (fabs(target - posMax - startPos - scrollVelocity) < dist)
|
||||||
endPos = target - posMax; // Loop around the start (max - 1 -> -1).
|
endPos = target - posMax; // Loop around the start (max - 1 -> -1).
|
||||||
|
|
||||||
|
// Make sure transitions do not animate in reverse.
|
||||||
|
bool changedDirection {false};
|
||||||
|
if (mPreviousScrollVelocity != 0 && mPreviousScrollVelocity != scrollVelocity)
|
||||||
|
changedDirection = true;
|
||||||
|
|
||||||
|
if (!changedDirection && scrollVelocity > 0 && endPos < startPos)
|
||||||
|
endPos = endPos + posMax;
|
||||||
|
|
||||||
|
if (!changedDirection && scrollVelocity < 0 && endPos > startPos)
|
||||||
|
endPos = endPos - posMax;
|
||||||
|
|
||||||
|
if (scrollVelocity != 0)
|
||||||
|
mPreviousScrollVelocity = scrollVelocity;
|
||||||
|
|
||||||
std::string transition_style {Settings::getInstance()->getString("TransitionStyle")};
|
std::string transition_style {Settings::getInstance()->getString("TransitionStyle")};
|
||||||
|
|
||||||
Animation* anim;
|
Animation* anim;
|
||||||
|
|
|
@ -90,6 +90,7 @@ private:
|
||||||
|
|
||||||
float mCamOffset;
|
float mCamOffset;
|
||||||
float mFadeOpacity;
|
float mFadeOpacity;
|
||||||
|
int mPreviousScrollVelocity;
|
||||||
|
|
||||||
bool mUpdatedGameCount;
|
bool mUpdatedGameCount;
|
||||||
bool mViewNeedsReload;
|
bool mViewNeedsReload;
|
||||||
|
|
|
@ -435,23 +435,19 @@ void CarouselComponent::onCursorChanged(const CursorState& state)
|
||||||
if (fabs(target - posMax - startPos - mScrollVelocity) < dist)
|
if (fabs(target - posMax - startPos - mScrollVelocity) < dist)
|
||||||
endPos = target - posMax; // Loop around the start (max - 1 -> -1).
|
endPos = target - posMax; // Loop around the start (max - 1 -> -1).
|
||||||
|
|
||||||
// This logic is only needed when there are two game systems, to prevent ugly jumps back
|
// Make sure there are no reverse jumps between logos.
|
||||||
// an forth when selecting the same direction rapidly several times in a row.
|
bool changedDirection {false};
|
||||||
if (posMax == 2) {
|
if (mPreviousScrollVelocity != 0 && mPreviousScrollVelocity != mScrollVelocity)
|
||||||
if (mPreviousScrollVelocity == 0)
|
changedDirection = true;
|
||||||
|
|
||||||
|
if (!changedDirection && mScrollVelocity > 0 && endPos < startPos)
|
||||||
|
endPos = endPos + posMax;
|
||||||
|
|
||||||
|
if (!changedDirection && mScrollVelocity < 0 && endPos > startPos)
|
||||||
|
endPos = endPos - posMax;
|
||||||
|
|
||||||
|
if (mScrollVelocity != 0)
|
||||||
mPreviousScrollVelocity = mScrollVelocity;
|
mPreviousScrollVelocity = mScrollVelocity;
|
||||||
else if (mScrollVelocity < 0 && startPos < endPos)
|
|
||||||
mPreviousScrollVelocity = -1;
|
|
||||||
else if (mScrollVelocity > 0 && startPos > endPos)
|
|
||||||
mPreviousScrollVelocity = 1;
|
|
||||||
}
|
|
||||||
if (mPreviousScrollVelocity != 0 && posMax == 2 && mScrollVelocity == mPreviousScrollVelocity) {
|
|
||||||
if (fabs(endPos - startPos) < 0.5 || fabs(endPos - startPos) > 1.5) {
|
|
||||||
(mScrollVelocity < 0) ? endPos -= 1 : endPos += 1;
|
|
||||||
(mCursor == 0) ? mCursor = 1 : mCursor = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// No need to animate transition, we're not going anywhere (probably mEntries.size() == 1).
|
// No need to animate transition, we're not going anywhere (probably mEntries.size() == 1).
|
||||||
if (endPos == mCamOffset)
|
if (endPos == mCamOffset)
|
||||||
|
|
Loading…
Reference in a new issue