From cf8801701a2ac3dfd57f5df0e216159dafad6f5e Mon Sep 17 00:00:00 2001 From: Aloshi Date: Thu, 1 May 2014 12:57:31 -0500 Subject: [PATCH] Improved "slide" transition. Still not happy with the implementation, it's not a true carousel like the SystemList. --- src/views/SystemView.cpp | 5 ++++- src/views/SystemView.h | 2 +- src/views/ViewController.cpp | 27 ++++++++++++++++++++++++--- src/views/ViewController.h | 1 + 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/views/SystemView.cpp b/src/views/SystemView.cpp index 6707742cb..f910b9b98 100644 --- a/src/views/SystemView.cpp +++ b/src/views/SystemView.cpp @@ -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) diff --git a/src/views/SystemView.h b/src/views/SystemView.h index 65664ff65..09aee10bc 100644 --- a/src/views/SystemView.h +++ b/src/views/SystemView.h @@ -22,7 +22,7 @@ class SystemView : public IList 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; diff --git a/src/views/ViewController.cpp b/src/views/ViewController.cpp index f1a3de88b..9698502e0 100644 --- a/src/views/ViewController.cpp +++ b/src/views/ViewController.cpp @@ -27,13 +27,23 @@ void ViewController::goToStart() goToSystemView(SystemData::sSystemVector.at(0)); } +int ViewController::getSystemId(SystemData* system) +{ + std::vector& 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()); diff --git a/src/views/ViewController.h b/src/views/ViewController.h index 52f9121f3..aab5f19e4 100644 --- a/src/views/ViewController.h +++ b/src/views/ViewController.h @@ -62,6 +62,7 @@ public: private: void playViewTransition(); + int getSystemId(SystemData* system); std::shared_ptr getGameListView(SystemData* system); std::shared_ptr getSystemListView();