mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Improvements to the startup animations and game launching logic.
This commit is contained in:
parent
635e7d2cdd
commit
1a35d29f19
|
@ -233,12 +233,12 @@ void SystemScreensaver::launchGame()
|
|||
{
|
||||
if (mCurrentGame != nullptr) {
|
||||
// Launching game
|
||||
ViewController::get()->triggerGameLaunch(mCurrentGame);
|
||||
ViewController::get()->goToGameList(mCurrentGame->getSystem());
|
||||
IGameListView* view = ViewController::get()->
|
||||
getGameListView(mCurrentGame->getSystem()).get();
|
||||
view->setCursor(mCurrentGame);
|
||||
ViewController::get()->cancelViewTransitions();
|
||||
ViewController::get()->launch(mCurrentGame);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,8 @@ public:
|
|||
std::vector<HelpPrompt> getHelpPrompts() override;
|
||||
virtual HelpStyle getHelpStyle() override;
|
||||
|
||||
CarouselType getCarouselType() { return mCarousel.type; };
|
||||
|
||||
protected:
|
||||
void onCursorChanged(const CursorState& state) override;
|
||||
virtual void onScroll() override {
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "Settings.h"
|
||||
#include "Sound.h"
|
||||
#include "SystemData.h"
|
||||
#include "SystemView.h"
|
||||
#include "Window.h"
|
||||
|
||||
ViewController* ViewController::sInstance = nullptr;
|
||||
|
@ -54,7 +55,8 @@ ViewController::ViewController(
|
|||
mWrappedViews(false),
|
||||
mFadeOpacity(0),
|
||||
mCancelledAnimation(false),
|
||||
mLockInput(false)
|
||||
mLockInput(false),
|
||||
mGameToLaunch(nullptr)
|
||||
{
|
||||
mState.viewing = NOTHING;
|
||||
}
|
||||
|
@ -172,6 +174,11 @@ void ViewController::restoreViewPosition()
|
|||
|
||||
void ViewController::goToSystemView(SystemData* system, bool playTransition)
|
||||
{
|
||||
bool applicationStartup = false;
|
||||
|
||||
if (mState.viewing == NOTHING)
|
||||
applicationStartup = true;
|
||||
|
||||
// Restore the X position for the view, if it was previously moved.
|
||||
if (mWrappedViews)
|
||||
restoreViewPosition();
|
||||
|
@ -198,11 +205,33 @@ void ViewController::goToSystemView(SystemData* system, bool playTransition)
|
|||
mCurrentView->setRenderView(true);
|
||||
PowerSaver::setState(true);
|
||||
|
||||
if (playTransition)
|
||||
// Application startup animation.
|
||||
if (applicationStartup) {
|
||||
mCamera.translation() = -mCurrentView->getPosition();
|
||||
if (Settings::getInstance()->getString("TransitionStyle") == "slide") {
|
||||
if (getSystemListView()->getCarouselType() == CarouselType::HORIZONTAL ||
|
||||
getSystemListView()->getCarouselType() == CarouselType::HORIZONTAL_WHEEL)
|
||||
mCamera.translation().y() += Renderer::getScreenHeight();
|
||||
else
|
||||
mCamera.translation().x() -= Renderer::getScreenWidth();
|
||||
updateHelpPrompts();
|
||||
}
|
||||
else if (Settings::getInstance()->getString("TransitionStyle") == "fade") {
|
||||
if (getSystemListView()->getCarouselType() == CarouselType::HORIZONTAL ||
|
||||
getSystemListView()->getCarouselType() == CarouselType::HORIZONTAL_WHEEL)
|
||||
mCamera.translation().y() += Renderer::getScreenHeight();
|
||||
else
|
||||
mCamera.translation().x() += Renderer::getScreenWidth();
|
||||
}
|
||||
else {
|
||||
updateHelpPrompts();
|
||||
}
|
||||
}
|
||||
|
||||
if (playTransition || applicationStartup)
|
||||
playViewTransition();
|
||||
else
|
||||
playViewTransition(true);
|
||||
|
||||
}
|
||||
|
||||
void ViewController::goToNextGameList()
|
||||
|
@ -306,14 +335,29 @@ void ViewController::goToGameList(SystemData* system)
|
|||
mWrappedViews = true;
|
||||
}
|
||||
|
||||
mCurrentView = getGameListView(system);
|
||||
|
||||
// Application startup animation, if starting in a gamelist rather than in the system view.
|
||||
if (mState.viewing == NOTHING) {
|
||||
mCamera.translation() = -mCurrentView->getPosition();
|
||||
if (Settings::getInstance()->getString("TransitionStyle") == "slide") {
|
||||
mCamera.translation().y() -= Renderer::getScreenHeight();
|
||||
updateHelpPrompts();
|
||||
}
|
||||
else if (Settings::getInstance()->getString("TransitionStyle") == "fade") {
|
||||
mCamera.translation().y() += Renderer::getScreenHeight() * 2;
|
||||
}
|
||||
else {
|
||||
updateHelpPrompts();
|
||||
}
|
||||
}
|
||||
|
||||
mState.viewing = GAME_LIST;
|
||||
mState.system = system;
|
||||
|
||||
if (mCurrentView)
|
||||
mCurrentView->onHide();
|
||||
|
||||
mCurrentView = getGameListView(system);
|
||||
|
||||
if (mCurrentView) {
|
||||
mCurrentView->onShow();
|
||||
mCurrentView->setRenderView(true);
|
||||
|
@ -387,7 +431,7 @@ void ViewController::onFileChanged(FileData* file, bool reloadGameList)
|
|||
it->second->onFileChanged(file, reloadGameList);
|
||||
}
|
||||
|
||||
void ViewController::launch(FileData* game, Vector3f center)
|
||||
void ViewController::launch(FileData* game)
|
||||
{
|
||||
if (game->getType() != GAME) {
|
||||
LOG(LogError) << "tried to launch something that isn't a game.";
|
||||
|
@ -404,7 +448,6 @@ void ViewController::launch(FileData* game, Vector3f center)
|
|||
|
||||
stopAnimation(1); // Make sure the fade in isn't still playing.
|
||||
mWindow->stopInfoPopup(); // Make sure we disable any existing info popup.
|
||||
mLockInput = true;
|
||||
|
||||
// Until a proper game launch screen is implemented, at least this will let the
|
||||
// user know that something is actually happening (in addition to the launch sound,
|
||||
|
@ -583,6 +626,11 @@ void ViewController::update(int deltaTime)
|
|||
mCurrentView->update(deltaTime);
|
||||
|
||||
updateSelf(deltaTime);
|
||||
|
||||
if (mGameToLaunch) {
|
||||
launch(mGameToLaunch);
|
||||
mGameToLaunch = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ViewController::render(const Transform4x4f& parentTrans)
|
||||
|
|
|
@ -59,9 +59,8 @@ public:
|
|||
void stopScrolling();
|
||||
|
||||
void onFileChanged(FileData* file, bool reloadGameList);
|
||||
|
||||
void launch(FileData* game, Vector3f centerCameraOn =
|
||||
Vector3f(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f, 0));
|
||||
void triggerGameLaunch(FileData* game) { mGameToLaunch = game; mLockInput = true; };
|
||||
bool getGameLaunchTriggered() { return (mGameToLaunch != nullptr); };
|
||||
|
||||
bool input(InputConfig* config, Input input) override;
|
||||
void update(int deltaTime) override;
|
||||
|
@ -109,6 +108,8 @@ private:
|
|||
ViewController(Window* window);
|
||||
static ViewController* sInstance;
|
||||
|
||||
void launch(FileData* game);
|
||||
|
||||
void playViewTransition(bool instant = false);
|
||||
int getSystemId(SystemData* system);
|
||||
// Restore view position if it was moved during wrap around.
|
||||
|
@ -125,6 +126,7 @@ private:
|
|||
float mFadeOpacity;
|
||||
bool mCancelledAnimation; // Needed only for the Fade transition style.
|
||||
bool mLockInput;
|
||||
FileData* mGameToLaunch;
|
||||
|
||||
State mState;
|
||||
};
|
||||
|
|
|
@ -189,7 +189,7 @@ std::string BasicGameListView::getQuickSystemSelectLeftButton()
|
|||
|
||||
void BasicGameListView::launch(FileData* game)
|
||||
{
|
||||
ViewController::get()->launch(game);
|
||||
ViewController::get()->triggerGameLaunch(game);
|
||||
}
|
||||
|
||||
void BasicGameListView::remove(FileData *game, bool deleteFile)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "SystemData.h"
|
||||
|
||||
#define FADE_IN_START_OPACITY 0.5f
|
||||
#define FADE_IN_TIME 300
|
||||
#define FADE_IN_TIME 650
|
||||
|
||||
DetailedGameListView::DetailedGameListView(
|
||||
Window* window,
|
||||
|
@ -435,11 +435,7 @@ void DetailedGameListView::updateInfoPanel()
|
|||
|
||||
void DetailedGameListView::launch(FileData* game)
|
||||
{
|
||||
Vector3f target(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f, 0);
|
||||
if (mImage.hasImage())
|
||||
target = Vector3f(mImage.getCenter().x(), mImage.getCenter().y(), 0);
|
||||
|
||||
ViewController::get()->launch(game, target);
|
||||
ViewController::get()->triggerGameLaunch(game);
|
||||
}
|
||||
|
||||
std::vector<TextComponent*> DetailedGameListView::getMDLabels()
|
||||
|
@ -470,6 +466,15 @@ std::vector<GuiComponent*> DetailedGameListView::getMDValues()
|
|||
return ret;
|
||||
}
|
||||
|
||||
void DetailedGameListView::update(int deltaTime)
|
||||
{
|
||||
BasicGameListView::update(deltaTime);
|
||||
mImage.update(deltaTime);
|
||||
|
||||
if (ViewController::get()->getGameLaunchTriggered() && mImage.isAnimationPlaying(0))
|
||||
mImage.finishAnimation(0);
|
||||
}
|
||||
|
||||
void DetailedGameListView::onShow()
|
||||
{
|
||||
mLastUpdated = nullptr;
|
||||
|
|
|
@ -24,6 +24,9 @@ public:
|
|||
virtual const char* getName() const override { return "detailed"; }
|
||||
virtual void launch(FileData* game) override;
|
||||
|
||||
protected:
|
||||
virtual void update(int deltaTime) override;
|
||||
|
||||
private:
|
||||
void updateInfoPanel();
|
||||
|
||||
|
|
|
@ -533,24 +533,7 @@ void GridGameListView::addPlaceholder(FileData* firstEntry)
|
|||
|
||||
void GridGameListView::launch(FileData* game)
|
||||
{
|
||||
float screenWidth = (float) Renderer::getScreenWidth();
|
||||
float screenHeight = (float) Renderer::getScreenHeight();
|
||||
|
||||
Vector3f target(screenWidth / 2.0f, screenHeight / 2.0f, 0);
|
||||
|
||||
if (mMarquee.hasImage() &&
|
||||
(mMarquee.getPosition().x() < screenWidth && mMarquee.getPosition().x() > 0.0f &&
|
||||
mMarquee.getPosition().y() < screenHeight && mMarquee.getPosition().y() > 0.0f))
|
||||
target = Vector3f(mMarquee.getCenter().x(), mMarquee.getCenter().y(), 0);
|
||||
else if (mImage.hasImage() &&
|
||||
(mImage.getPosition().x() < screenWidth && mImage.getPosition().x() > 2.0f &&
|
||||
mImage.getPosition().y() < screenHeight && mImage.getPosition().y() > 2.0f))
|
||||
target = Vector3f(mImage.getCenter().x(), mImage.getCenter().y(), 0);
|
||||
else if (mVideo->getPosition().x() < screenWidth && mVideo->getPosition().x() > 0.0f &&
|
||||
mVideo->getPosition().y() < screenHeight && mVideo->getPosition().y() > 0.0f)
|
||||
target = Vector3f(mVideo->getCenter().x(), mVideo->getCenter().y(), 0);
|
||||
|
||||
ViewController::get()->launch(game, target);
|
||||
ViewController::get()->triggerGameLaunch(game);
|
||||
}
|
||||
|
||||
void GridGameListView::remove(FileData *game, bool deleteFile)
|
||||
|
|
|
@ -478,38 +478,7 @@ void VideoGameListView::updateInfoPanel()
|
|||
|
||||
void VideoGameListView::launch(FileData* game)
|
||||
{
|
||||
float screenWidth = static_cast<float>(Renderer::getScreenWidth());
|
||||
float screenHeight = static_cast<float>(Renderer::getScreenHeight());
|
||||
|
||||
Vector3f target(screenWidth / 2.0f, screenHeight / 2.0f, 0);
|
||||
|
||||
if (mMarquee.hasImage() &&
|
||||
(mMarquee.getPosition().x() < screenWidth && mMarquee.getPosition().x() > 0.0f &&
|
||||
mMarquee.getPosition().y() < screenHeight && mMarquee.getPosition().y() > 0.0f))
|
||||
target = Vector3f(mMarquee.getCenter().x(), mMarquee.getCenter().y(), 0);
|
||||
|
||||
else if (mThumbnail.hasImage() &&
|
||||
(mThumbnail.getPosition().x() < screenWidth && mThumbnail.getPosition().x() > 2.0f &&
|
||||
mThumbnail.getPosition().y() < screenHeight && mThumbnail.getPosition().y() > 2.0f))
|
||||
target = Vector3f(mThumbnail.getCenter().x(), mThumbnail.getCenter().y(), 0);
|
||||
|
||||
else if (mImage.hasImage() &&
|
||||
(mImage.getPosition().x() < screenWidth && mImage.getPosition().x() > 2.0f &&
|
||||
mImage.getPosition().y() < screenHeight && mImage.getPosition().y() > 2.0f))
|
||||
target = Vector3f(mImage.getCenter().x(), mImage.getCenter().y(), 0);
|
||||
|
||||
else if (mHeaderImage.hasImage() &&
|
||||
(mHeaderImage.getPosition().x() < screenWidth &&
|
||||
mHeaderImage.getPosition().x() > 0.0f &&
|
||||
mHeaderImage.getPosition().y() < screenHeight &&
|
||||
mHeaderImage.getPosition().y() > 0.0f))
|
||||
target = Vector3f(mHeaderImage.getCenter().x(), mHeaderImage.getCenter().y(), 0);
|
||||
|
||||
else if (mVideo->getPosition().x() < screenWidth && mVideo->getPosition().x() > 0.0f &&
|
||||
mVideo->getPosition().y() < screenHeight && mVideo->getPosition().y() > 0.0f)
|
||||
target = Vector3f(mVideo->getCenter().x(), mVideo->getCenter().y(), 0);
|
||||
|
||||
ViewController::get()->launch(game, target);
|
||||
ViewController::get()->triggerGameLaunch(game);
|
||||
}
|
||||
|
||||
std::vector<TextComponent*> VideoGameListView::getMDLabels()
|
||||
|
@ -549,6 +518,9 @@ void VideoGameListView::update(int deltaTime)
|
|||
|
||||
BasicGameListView::update(deltaTime);
|
||||
mVideo->update(deltaTime);
|
||||
|
||||
if (ViewController::get()->getGameLaunchTriggered() && mVideo->isAnimationPlaying(0))
|
||||
mVideo->finishAnimation(0);
|
||||
}
|
||||
|
||||
void VideoGameListView::onShow()
|
||||
|
|
Loading…
Reference in a new issue