Commit ef79c054 authored by Saket Dandawate's avatar Saket Dandawate Committed by Subs

Added Instant Transition

parent 7be3bb5c
......@@ -501,6 +501,7 @@ GuiMenu::GuiMenu(Window *window) : GuiComponent(window), mMenu(window, _("MAIN M
std::vector<std::string> transitions;
transitions.push_back("fade");
transitions.push_back("slide");
transitions.push_back("instant");
for (auto it = transitions.begin(); it != transitions.end(); it++)
transition_style->add(*it, *it,
Settings::getInstance()->getString("TransitionStyle") == *it);
......
......@@ -331,7 +331,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(
......@@ -359,7 +360,7 @@ void SystemView::onCursorChanged(const CursorState& state)
}, 500);
}
else{ // slide
else if (transition_style == "slide"){ // slide
anim = new LambdaAnimation(
[startPos, endPos, posMax, this](float t)
{
......@@ -373,6 +374,15 @@ void SystemView::onCursorChanged(const CursorState& state)
this->mCamOffset = f;
this->mExtrasCamOffset = f;
}, 500);
} else {
// instant
anim = new LambdaAnimation(
[this, endPos](float t)
{
this->mCamOffset = endPos;
this->mExtrasCamOffset = endPos;
}, 1);
}
setAnimation(anim, 0, nullptr, false, 0);
......
......@@ -195,7 +195,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
......@@ -223,10 +224,18 @@ void ViewController::playViewTransition()
}else{
advanceAnimation(0, (int)(mFadeOpacity * FADE_DURATION));
}
}else{
// slide
} else if (transition_style == "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();
}
}
......@@ -252,7 +261,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) {
......@@ -267,7 +277,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"){
// 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]
{
......@@ -277,6 +287,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);
});
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment