Merge pull request #170 from hex007/separate-carousel-transition

Move Carousel transition to separate switch
This commit is contained in:
Jools Wills 2017-07-07 19:36:04 +01:00 committed by GitHub
commit acf4223f96
4 changed files with 24 additions and 25 deletions

View file

@ -170,12 +170,17 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN
s->addWithLabel("QUICK SYSTEM SELECT", quick_sys_select);
s->addSaveFunc([quick_sys_select] { Settings::getInstance()->setBool("QuickSystemSelect", quick_sys_select->getState()); });
// carousel transition option
auto move_carousel = std::make_shared<SwitchComponent>(mWindow);
move_carousel->setState(Settings::getInstance()->getBool("MoveCarousel"));
s->addWithLabel("CAROUSEL TRANSITIONS", move_carousel);
s->addSaveFunc([move_carousel] { Settings::getInstance()->setBool("MoveCarousel", move_carousel->getState()); });
// transition style
auto transition_style = std::make_shared< OptionListComponent<std::string> >(mWindow, "TRANSITION STYLE", false);
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);

View file

@ -243,12 +243,13 @@ void SystemView::onCursorChanged(const CursorState& state)
return;
Animation* anim;
bool move_carousel = Settings::getInstance()->getBool("MoveCarousel");
std::string transition_style = Settings::getInstance()->getString("TransitionStyle");
if(transition_style == "fade")
{
float startExtrasFade = mExtrasFadeOpacity;
anim = new LambdaAnimation(
[startExtrasFade, startPos, endPos, posMax, this](float t)
[this, startExtrasFade, startPos, endPos, posMax, move_carousel](float t)
{
t -= 1;
float f = lerp<float>(startPos, endPos, t*t*t + 1);
@ -257,7 +258,7 @@ void SystemView::onCursorChanged(const CursorState& state)
if(f >= posMax)
f -= posMax;
this->mCamOffset = f;
this->mCamOffset = move_carousel ? f : endPos;
t += 1;
if(t < 0.3f)
@ -274,7 +275,7 @@ void SystemView::onCursorChanged(const CursorState& state)
} else if (transition_style == "slide") {
// slide
anim = new LambdaAnimation(
[this, startPos, endPos, posMax](float t)
[this, startPos, endPos, posMax, move_carousel](float t)
{
t -= 1;
float f = lerp<float>(startPos, endPos, t*t*t + 1);
@ -283,32 +284,24 @@ void SystemView::onCursorChanged(const CursorState& state)
if(f >= posMax)
f -= posMax;
this->mCamOffset = f;
this->mCamOffset = move_carousel ? f : endPos;
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, startPos, endPos, posMax, move_carousel ](float t)
{
this->mCamOffset = endPos;
t -= 1;
float f = lerp<float>(startPos, endPos, t*t*t + 1);
if(f < 0)
f += posMax;
if(f >= posMax)
f -= posMax;
this->mCamOffset = move_carousel ? f : endPos;
this->mExtrasCamOffset = endPos;
}, 1);
}, move_carousel ? 500 : 1);
}

View file

@ -189,7 +189,7 @@ void ViewController::playViewTransition()
}else{
advanceAnimation(0, (int)(mFadeOpacity * FADE_DURATION));
}
} else if (transition_style == "slide" || transition_style == "simple slide"){
} else if (transition_style == "slide"){
// slide or simple slide
setAnimation(new MoveCameraAnimation(mCamera, target));
updateHelpPrompts(); // update help prompts immediately
@ -246,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 if (transition_style == "slide" || transition_style == "simple slide"){
} 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]
{

View file

@ -60,6 +60,7 @@ void Settings::setDefaults()
mBoolMap["IgnoreGamelist"] = false;
mBoolMap["HideConsole"] = true;
mBoolMap["QuickSystemSelect"] = true;
mBoolMap["MoveCarousel"] = true;
mBoolMap["SaveGamelistsOnExit"] = true;
mBoolMap["Debug"] = false;