mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-29 19:55:37 +00:00
Merge pull request #149 from hex007/additional-transitions
Additional transitions
This commit is contained in:
commit
b078bdddd7
|
@ -127,6 +127,8 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN
|
|||
std::vector<std::string> transitions;
|
||||
transitions.push_back("fade");
|
||||
transitions.push_back("slide");
|
||||
transitions.push_back("simple slide");
|
||||
transitions.push_back("instant");
|
||||
for(auto it = transitions.begin(); it != transitions.end(); it++)
|
||||
transition_style->add(*it, *it, Settings::getInstance()->getString("TransitionStyle") == *it);
|
||||
s->addWithLabel("TRANSITION STYLE", transition_style);
|
||||
|
|
|
@ -237,7 +237,8 @@ void SystemView::onCursorChanged(const CursorState& state)
|
|||
return;
|
||||
|
||||
Animation* anim;
|
||||
if(Settings::getInstance()->getString("TransitionStyle") == "fade")
|
||||
std::string transition_style = Settings::getInstance()->getString("TransitionStyle");
|
||||
if(transition_style == "fade")
|
||||
{
|
||||
float startExtrasFade = mExtrasFadeOpacity;
|
||||
anim = new LambdaAnimation(
|
||||
|
@ -264,10 +265,10 @@ void SystemView::onCursorChanged(const CursorState& state)
|
|||
this->mExtrasCamOffset = endPos;
|
||||
|
||||
}, 500);
|
||||
}
|
||||
else{ // slide
|
||||
} else if (transition_style == "slide") {
|
||||
// slide
|
||||
anim = new LambdaAnimation(
|
||||
[startPos, endPos, posMax, this](float t)
|
||||
[this, startPos, endPos, posMax](float t)
|
||||
{
|
||||
t -= 1;
|
||||
float f = lerp<float>(startPos, endPos, t*t*t + 1);
|
||||
|
@ -279,8 +280,32 @@ void SystemView::onCursorChanged(const CursorState& state)
|
|||
this->mCamOffset = f;
|
||||
this->mExtrasCamOffset = f;
|
||||
}, 500);
|
||||
} else if (transition_style == "simple slide") {
|
||||
// simple slide
|
||||
anim = new LambdaAnimation(
|
||||
[this, startPos, endPos, posMax](float t)
|
||||
{
|
||||
t -= 1;
|
||||
float f = lerp<float>(startPos, endPos, t*t*t + 1);
|
||||
if(f < 0)
|
||||
f += posMax;
|
||||
if(f >= posMax)
|
||||
f -= posMax;
|
||||
|
||||
this->mCamOffset = f;
|
||||
this->mExtrasCamOffset = endPos;
|
||||
}, 500);
|
||||
} else {
|
||||
// instant
|
||||
anim = new LambdaAnimation(
|
||||
[this, endPos](float t)
|
||||
{
|
||||
this->mCamOffset = endPos;
|
||||
this->mExtrasCamOffset = endPos;
|
||||
}, 1);
|
||||
}
|
||||
|
||||
|
||||
setAnimation(anim, 0, nullptr, false, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,8 @@ void ViewController::playViewTransition()
|
|||
if(target == -mCamera.translation() && !isAnimationPlaying(0))
|
||||
return;
|
||||
|
||||
if(Settings::getInstance()->getString("TransitionStyle") == "fade")
|
||||
std::string transition_style = Settings::getInstance()->getString("TransitionStyle");
|
||||
if(transition_style == "fade")
|
||||
{
|
||||
// fade
|
||||
// stop whatever's currently playing, leaving mFadeOpacity wherever it is
|
||||
|
@ -188,10 +189,18 @@ void ViewController::playViewTransition()
|
|||
}else{
|
||||
advanceAnimation(0, (int)(mFadeOpacity * FADE_DURATION));
|
||||
}
|
||||
}else{
|
||||
// slide
|
||||
} else if (transition_style == "slide" || transition_style == "simple slide"){
|
||||
// slide or simple slide
|
||||
setAnimation(new MoveCameraAnimation(mCamera, target));
|
||||
updateHelpPrompts(); // update help prompts immediately
|
||||
} else {
|
||||
// instant
|
||||
setAnimation(new LambdaAnimation(
|
||||
[this, target](float t)
|
||||
{
|
||||
this->mCamera.translation() = -target;
|
||||
}, 1));
|
||||
updateHelpPrompts();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,7 +230,8 @@ void ViewController::launch(FileData* game, Eigen::Vector3f center)
|
|||
stopAnimation(1); // make sure the fade in isn't still playing
|
||||
mLockInput = true;
|
||||
|
||||
if(Settings::getInstance()->getString("TransitionStyle") == "fade")
|
||||
std::string transition_style = Settings::getInstance()->getString("TransitionStyle");
|
||||
if(transition_style == "fade")
|
||||
{
|
||||
// fade out, launch game, fade back in
|
||||
auto fadeFunc = [this](float t) {
|
||||
|
@ -236,7 +246,7 @@ void ViewController::launch(FileData* game, Eigen::Vector3f center)
|
|||
setAnimation(new LambdaAnimation(fadeFunc, 800), 0, nullptr, true);
|
||||
this->onFileChanged(game, FILE_METADATA_CHANGED);
|
||||
});
|
||||
}else{
|
||||
} else if (transition_style == "slide" || transition_style == "simple slide"){
|
||||
// move camera to zoom in on center + fade out, launch game, come back in
|
||||
setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 1500), 0, [this, origCamera, center, game]
|
||||
{
|
||||
|
@ -246,6 +256,15 @@ void ViewController::launch(FileData* game, Eigen::Vector3f center)
|
|||
setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 600), 0, nullptr, true);
|
||||
this->onFileChanged(game, FILE_METADATA_CHANGED);
|
||||
});
|
||||
} else {
|
||||
setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 10), 0, [this, origCamera, center, game]
|
||||
{
|
||||
game->getSystem()->launchGame(mWindow, game);
|
||||
mCamera = origCamera;
|
||||
mLockInput = false;
|
||||
setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 10), 0, nullptr, true);
|
||||
this->onFileChanged(game, FILE_METADATA_CHANGED);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue