Lock input during launch animation.

This commit is contained in:
Aloshi 2013-12-13 14:38:34 -06:00
parent 7e9b20fac5
commit 1398785468
2 changed files with 7 additions and 1 deletions

View file

@ -10,7 +10,7 @@
#include "../animations/LambdaAnimation.h" #include "../animations/LambdaAnimation.h"
ViewController::ViewController(Window* window) ViewController::ViewController(Window* window)
: GuiComponent(window), mCurrentView(nullptr), mCamera(Eigen::Affine3f::Identity()), mFadeOpacity(1) : GuiComponent(window), mCurrentView(nullptr), mCamera(Eigen::Affine3f::Identity()), mFadeOpacity(1), mLockInput(false)
{ {
// slot 1 so the fade carries over // slot 1 so the fade carries over
setAnimation(new LambdaAnimation([&] (float t) { mFadeOpacity = lerp<float>(1.0f, 0.0f, t); }, 900), nullptr, false, 1); setAnimation(new LambdaAnimation([&] (float t) { mFadeOpacity = lerp<float>(1.0f, 0.0f, t); }, 900), nullptr, false, 1);
@ -105,10 +105,12 @@ void ViewController::launch(FileData* game, Eigen::Vector3f center)
center += mCurrentView->getPosition(); center += mCurrentView->getPosition();
stopAnimation(1); // make sure the fade in isn't still playing stopAnimation(1); // make sure the fade in isn't still playing
mLockInput = true;
setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 1500), [this, origCamera, center, game] setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 1500), [this, origCamera, center, game]
{ {
game->getSystem()->launchGame(mWindow, game); game->getSystem()->launchGame(mWindow, game);
mCamera = origCamera; mCamera = origCamera;
mLockInput = false;
setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 600), nullptr, true); setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 600), nullptr, true);
}); });
} }
@ -171,6 +173,9 @@ std::shared_ptr<SystemListView> ViewController::getSystemListView()
bool ViewController::input(InputConfig* config, Input input) bool ViewController::input(InputConfig* config, Input input)
{ {
if(mLockInput)
return true;
if(mCurrentView) if(mCurrentView)
return mCurrentView->input(config, input); return mCurrentView->input(config, input);

View file

@ -64,6 +64,7 @@ private:
Eigen::Affine3f mCamera; Eigen::Affine3f mCamera;
float mFadeOpacity; float mFadeOpacity;
bool mLockInput;
State mState; State mState;
}; };