Fixed multiple issues in SystemView.

Also set the carousel zIndex value to 40 intead of 50 for legacy themes.
This commit is contained in:
Leon Styhre 2022-09-23 17:19:24 +02:00
parent f620df4dff
commit 1839dfc31a
2 changed files with 41 additions and 16 deletions

View file

@ -52,6 +52,12 @@ SystemView::~SystemView()
}
}
void SystemView::onShow()
{
if (mFadeTransitions)
finishAnimation(0);
}
void SystemView::onTransition()
{
for (auto& anim : mSystemElements[mPrimary->getCursor()].lottieAnimComponents)
@ -112,6 +118,7 @@ bool SystemView::input(InputConfig* config, Input input)
config->isMappedTo("rightthumbstickclick", input))) {
// Get a random system and jump to it.
NavigationSounds::getInstance().playThemeNavigationSound(SYSTEMBROWSESOUND);
mPrimary->stopScrolling();
mPrimary->setCursor(SystemData::getRandomSystem(mPrimary->getSelected()));
return true;
}
@ -217,15 +224,14 @@ void SystemView::onCursorChanged(const CursorState& state)
int cursor {mPrimary->getCursor()};
// Avoid double updates.
if (cursor == mLastCursor)
return;
mLastCursor = cursor;
if (cursor != mLastCursor) {
for (auto& selector : mSystemElements[cursor].gameSelectors) {
if (selector->getGameSelection() == GameSelectorComponent::GameSelection::RANDOM)
selector->setNeedsRefresh();
}
}
mLastCursor = cursor;
for (auto& video : mSystemElements[cursor].videoComponents)
video->setStaticVideo();
@ -397,7 +403,8 @@ void SystemView::populate()
if (mCarousel == nullptr) {
mCarousel = std::make_unique<CarouselComponent<SystemData*>>();
mPrimary = mCarousel.get();
mPrimary->setDefaultZIndex(50.0f);
// For legacy themes the carousel has a zIndex value of 40 instead of 50.
mPrimary->setDefaultZIndex(40.0f);
mPrimary->setCursorChangedCallback(
[&](const CursorState& state) { onCursorChanged(state); });
mPrimary->setCancelTransitionsCallback([&] {
@ -1180,8 +1187,8 @@ void SystemView::legacyApplyTheme(const std::shared_ptr<ThemeData>& theme)
Font::get(static_cast<int>(0.035f * mSize.y), Font::getDefaultPath()));
mLegacySystemInfo->setColor(0x000000FF);
mLegacySystemInfo->setUppercase(true);
mLegacySystemInfo->setZIndex(49.0f);
mLegacySystemInfo->setDefaultZIndex(49.0f);
mLegacySystemInfo->setZIndex(50.0f);
mLegacySystemInfo->setDefaultZIndex(50.0f);
const ThemeData::ThemeElement* sysInfoElem {
theme->getElement("system", "text_systemInfo", "text")};
@ -1244,6 +1251,12 @@ void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary)
if ((mFadeTransitions || element->getDimming() != 1.0f) &&
element->getZIndex() < primaryZIndex)
element->setDimming(1.0f - mFadeOpacity);
if (mFadeTransitions && isAnimationPlaying(0))
element->setOpacity(mMaxFade ? 1.0f - mFadeOpacity : 0.0f);
else
element->setOpacity(1.0f);
if (mNavigated && mMaxFade)
continue;
element->render(elementTrans);
}
}
@ -1262,9 +1275,15 @@ void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary)
}
}
if (mLegacyMode && !abovePrimary) {
if (mFadeTransitions)
mLegacySystemInfo->setDimming(1.0f - mFadeOpacity);
if (mLegacyMode) {
if (mFadeTransitions && !abovePrimary) {
if (mFadeTransitions && isAnimationPlaying(0))
mLegacySystemInfo->setOpacity(mMaxFade ? 1.0f - mFadeOpacity : 0.0f);
else
mLegacySystemInfo->setOpacity(1.0f);
}
if ((abovePrimary && mLegacySystemInfo->getZIndex() > 40.0f) ||
(!abovePrimary && mLegacySystemInfo->getZIndex() <= 40.0f))
mLegacySystemInfo->render(elementTrans);
}

View file

@ -36,6 +36,7 @@ public:
SystemView();
~SystemView();
void onShow() override;
void onTransition() override;
void goToSystem(SystemData* system, bool animate);
@ -48,9 +49,14 @@ public:
bool isSystemAnimationPlaying(unsigned char slot) { return mPrimary->isAnimationPlaying(slot); }
void finishSystemAnimation(unsigned char slot)
{
if (mFadeTransitions) {
mPrimary->finishAnimation(slot);
}
else {
finishAnimation(slot);
mPrimary->finishAnimation(slot);
}
}
PrimaryComponent<SystemData*>::PrimaryType getPrimaryType() { return mPrimaryType; }
CarouselComponent<SystemData*>::CarouselType getCarouselType()