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() void SystemView::onTransition()
{ {
for (auto& anim : mSystemElements[mPrimary->getCursor()].lottieAnimComponents) for (auto& anim : mSystemElements[mPrimary->getCursor()].lottieAnimComponents)
@ -112,6 +118,7 @@ bool SystemView::input(InputConfig* config, Input input)
config->isMappedTo("rightthumbstickclick", input))) { config->isMappedTo("rightthumbstickclick", input))) {
// Get a random system and jump to it. // Get a random system and jump to it.
NavigationSounds::getInstance().playThemeNavigationSound(SYSTEMBROWSESOUND); NavigationSounds::getInstance().playThemeNavigationSound(SYSTEMBROWSESOUND);
mPrimary->stopScrolling();
mPrimary->setCursor(SystemData::getRandomSystem(mPrimary->getSelected())); mPrimary->setCursor(SystemData::getRandomSystem(mPrimary->getSelected()));
return true; return true;
} }
@ -217,16 +224,15 @@ void SystemView::onCursorChanged(const CursorState& state)
int cursor {mPrimary->getCursor()}; int cursor {mPrimary->getCursor()};
// Avoid double updates. // Avoid double updates.
if (cursor == mLastCursor) if (cursor != mLastCursor) {
return; for (auto& selector : mSystemElements[cursor].gameSelectors) {
if (selector->getGameSelection() == GameSelectorComponent::GameSelection::RANDOM)
selector->setNeedsRefresh();
}
}
mLastCursor = cursor; mLastCursor = cursor;
for (auto& selector : mSystemElements[cursor].gameSelectors) {
if (selector->getGameSelection() == GameSelectorComponent::GameSelection::RANDOM)
selector->setNeedsRefresh();
}
for (auto& video : mSystemElements[cursor].videoComponents) for (auto& video : mSystemElements[cursor].videoComponents)
video->setStaticVideo(); video->setStaticVideo();
@ -397,7 +403,8 @@ void SystemView::populate()
if (mCarousel == nullptr) { if (mCarousel == nullptr) {
mCarousel = std::make_unique<CarouselComponent<SystemData*>>(); mCarousel = std::make_unique<CarouselComponent<SystemData*>>();
mPrimary = mCarousel.get(); 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( mPrimary->setCursorChangedCallback(
[&](const CursorState& state) { onCursorChanged(state); }); [&](const CursorState& state) { onCursorChanged(state); });
mPrimary->setCancelTransitionsCallback([&] { 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())); Font::get(static_cast<int>(0.035f * mSize.y), Font::getDefaultPath()));
mLegacySystemInfo->setColor(0x000000FF); mLegacySystemInfo->setColor(0x000000FF);
mLegacySystemInfo->setUppercase(true); mLegacySystemInfo->setUppercase(true);
mLegacySystemInfo->setZIndex(49.0f); mLegacySystemInfo->setZIndex(50.0f);
mLegacySystemInfo->setDefaultZIndex(49.0f); mLegacySystemInfo->setDefaultZIndex(50.0f);
const ThemeData::ThemeElement* sysInfoElem { const ThemeData::ThemeElement* sysInfoElem {
theme->getElement("system", "text_systemInfo", "text")}; 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) && if ((mFadeTransitions || element->getDimming() != 1.0f) &&
element->getZIndex() < primaryZIndex) element->getZIndex() < primaryZIndex)
element->setDimming(1.0f - mFadeOpacity); 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); element->render(elementTrans);
} }
} }
@ -1262,10 +1275,16 @@ void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary)
} }
} }
if (mLegacyMode && !abovePrimary) { if (mLegacyMode) {
if (mFadeTransitions) if (mFadeTransitions && !abovePrimary) {
mLegacySystemInfo->setDimming(1.0f - mFadeOpacity); if (mFadeTransitions && isAnimationPlaying(0))
mLegacySystemInfo->render(elementTrans); 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);
} }
mRenderer->popClipRect(); mRenderer->popClipRect();

View file

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