From 234252131615229b548923ab391290c7891e5c0e Mon Sep 17 00:00:00 2001 From: Aloshi Date: Tue, 27 May 2014 17:12:08 -0500 Subject: [PATCH] "Fade" transition style now affects system list extra transition style. --- src/views/SystemView.cpp | 68 +++++++++++++++++++++++++++++++++------- src/views/SystemView.h | 2 ++ 2 files changed, 58 insertions(+), 12 deletions(-) diff --git a/src/views/SystemView.cpp b/src/views/SystemView.cpp index 702f9de42..c8d6ab2f0 100644 --- a/src/views/SystemView.cpp +++ b/src/views/SystemView.cpp @@ -17,6 +17,8 @@ SystemView::SystemView(Window* window) : IList(wind mSystemInfo(window, "SYSTEM INFO", Font::get(FONT_SIZE_SMALL), 0x33333300, ALIGN_CENTER) { mCamOffset = 0; + mExtrasCamOffset = 0; + mExtrasFadeOpacity = 0.0f; setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight()); @@ -151,17 +153,51 @@ void SystemView::onCursorChanged(const CursorState& state) if(abs(target - posMax - startPos) < dist) endPos = target - posMax; // loop around the start (max - 1 -> -1) - Animation* anim = new LambdaAnimation( - [startPos, endPos, posMax, this] (float t) + Animation* anim; + if(Settings::getInstance()->getString("TransitionStyle") == "fade") { - t -= 1; - float f = lerp(startPos, endPos, t*t*t + 1); - if(f < 0) - f += posMax; - if(f >= posMax) - f -= posMax; - this->mCamOffset = f; - }, 500); + float startExtrasFade = mExtrasFadeOpacity; + anim = new LambdaAnimation( + [startExtrasFade, startPos, endPos, posMax, this](float t) + { + t -= 1; + float f = lerp(startPos, endPos, t*t*t + 1); + if(f < 0) + f += posMax; + if(f >= posMax) + f -= posMax; + + this->mCamOffset = f; + + t += 1; + if(t < 0.3f) + this->mExtrasFadeOpacity = lerp(0.0f, 1.0f, t / 0.3f + startExtrasFade); + else if(t < 0.7f) + this->mExtrasFadeOpacity = 1.0f; + else + this->mExtrasFadeOpacity = lerp(1.0f, 0.0f, (t - 0.7f) / 0.3f); + + if(t > 0.5f) + this->mExtrasCamOffset = endPos; + + }, 500); + }else{ // slide + anim = new LambdaAnimation( + [startPos, endPos, posMax, this](float t) + { + t -= 1; + float f = lerp(startPos, endPos, t*t*t + 1); + if(f < 0) + f += posMax; + if(f >= posMax) + f -= posMax; + + this->mCamOffset = f; + this->mExtrasCamOffset = f; + }, 500); + } + + setAnimation(anim, 0, nullptr, false, 0); // animate mSystemInfo's opacity (fade out, wait, fade back in) @@ -214,7 +250,8 @@ void SystemView::render(const Eigen::Affine3f& parentTrans) // draw background extras Eigen::Affine3f extrasTrans = trans; - for(int i = center - 1; i < center + 2; i++) + int extrasCenter = (int)mExtrasCamOffset; + for(int i = extrasCenter - 1; i < extrasCenter + 2; i++) { int index = i; while(index < 0) @@ -222,11 +259,18 @@ void SystemView::render(const Eigen::Affine3f& parentTrans) while(index >= (int)mEntries.size()) index -= mEntries.size(); - extrasTrans.translation() = trans.translation() + Eigen::Vector3f((i - mCamOffset) * mSize.x(), 0, 0); + extrasTrans.translation() = trans.translation() + Eigen::Vector3f((i - mExtrasCamOffset) * mSize.x(), 0, 0); mEntries.at(index).data.backgroundExtras->render(extrasTrans); } + // fade extras if necessary + if(mExtrasFadeOpacity) + { + Renderer::setMatrix(trans); + Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), 0x00000000 | (unsigned char)(mExtrasFadeOpacity * 255)); + } + // draw logos float xOff = (mSize.x() - logoSize().x())/2 - (mCamOffset * logoSizeX); float yOff = (mSize.y() - logoSize().y())/2; diff --git a/src/views/SystemView.h b/src/views/SystemView.h index 09aee10bc..69bb4952c 100644 --- a/src/views/SystemView.h +++ b/src/views/SystemView.h @@ -42,4 +42,6 @@ private: // unit is list index float mCamOffset; + float mExtrasCamOffset; + float mExtrasFadeOpacity; };