Improved "slide" transition.

Still not happy with the implementation, it's not a true carousel like the SystemList.
This commit is contained in:
Aloshi 2014-05-01 12:57:31 -05:00
parent fd5508a749
commit cf8801701a
4 changed files with 30 additions and 5 deletions

View file

@ -79,9 +79,12 @@ void SystemView::populate()
}
}
void SystemView::goToSystem(SystemData* system)
void SystemView::goToSystem(SystemData* system, bool animate)
{
setCursor(system);
if(!animate)
finishAnimation(0);
}
bool SystemView::input(InputConfig* config, Input input)

View file

@ -22,7 +22,7 @@ class SystemView : public IList<SystemViewData, SystemData*>
public:
SystemView(Window* window);
void goToSystem(SystemData* system);
void goToSystem(SystemData* system, bool animate);
bool input(InputConfig* config, Input input) override;
void update(int deltaTime) override;

View file

@ -27,13 +27,23 @@ void ViewController::goToStart()
goToSystemView(SystemData::sSystemVector.at(0));
}
int ViewController::getSystemId(SystemData* system)
{
std::vector<SystemData*>& sysVec = SystemData::sSystemVector;
return std::find(sysVec.begin(), sysVec.end(), system) - sysVec.begin();
}
void ViewController::goToSystemView(SystemData* system)
{
mState.viewing = SYSTEM_SELECT;
mState.system = system;
getSystemListView()->goToSystem(system);
mCurrentView = getSystemListView();
auto systemList = getSystemListView();
systemList->setPosition(getSystemId(system) * (float)Renderer::getScreenWidth(), systemList->getPosition().y());
systemList->goToSystem(system, false);
mCurrentView = systemList;
updateHelpPrompts();
playViewTransition();
}
@ -56,6 +66,17 @@ void ViewController::goToPrevGameList()
void ViewController::goToGameList(SystemData* system)
{
if(mState.viewing == SYSTEM_SELECT)
{
// move system list
auto sysList = getSystemListView();
float offX = sysList->getPosition().x();
int sysId = getSystemId(system);
sysList->setPosition(sysId * (float)Renderer::getScreenWidth(), sysList->getPosition().y());
offX = sysList->getPosition().x() - offX;
mCamera.translation().x() -= offX;
}
mState.viewing = GAME_LIST;
mState.system = system;
@ -310,7 +331,7 @@ void ViewController::reloadAll()
mCurrentView = getGameListView(mState.getSystem());
}else if(mState.viewing == SYSTEM_SELECT)
{
mSystemListView->goToSystem(mState.getSystem());
mSystemListView->goToSystem(mState.getSystem(), false);
mCurrentView = mSystemListView;
}else{
goToSystemView(SystemData::sSystemVector.front());

View file

@ -62,6 +62,7 @@ public:
private:
void playViewTransition();
int getSystemId(SystemData* system);
std::shared_ptr<IGameListView> getGameListView(SystemData* system);
std::shared_ptr<SystemView> getSystemListView();