mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-12-01 10:35: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) {
|
if (mCurrentGame != nullptr) {
|
||||||
// Launching game
|
// Launching game
|
||||||
|
ViewController::get()->triggerGameLaunch(mCurrentGame);
|
||||||
ViewController::get()->goToGameList(mCurrentGame->getSystem());
|
ViewController::get()->goToGameList(mCurrentGame->getSystem());
|
||||||
IGameListView* view = ViewController::get()->
|
IGameListView* view = ViewController::get()->
|
||||||
getGameListView(mCurrentGame->getSystem()).get();
|
getGameListView(mCurrentGame->getSystem()).get();
|
||||||
view->setCursor(mCurrentGame);
|
view->setCursor(mCurrentGame);
|
||||||
ViewController::get()->cancelViewTransitions();
|
ViewController::get()->cancelViewTransitions();
|
||||||
ViewController::get()->launch(mCurrentGame);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,8 @@ public:
|
||||||
std::vector<HelpPrompt> getHelpPrompts() override;
|
std::vector<HelpPrompt> getHelpPrompts() override;
|
||||||
virtual HelpStyle getHelpStyle() override;
|
virtual HelpStyle getHelpStyle() override;
|
||||||
|
|
||||||
|
CarouselType getCarouselType() { return mCarousel.type; };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onCursorChanged(const CursorState& state) override;
|
void onCursorChanged(const CursorState& state) override;
|
||||||
virtual void onScroll() override {
|
virtual void onScroll() override {
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
#include "SystemData.h"
|
#include "SystemData.h"
|
||||||
|
#include "SystemView.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
ViewController* ViewController::sInstance = nullptr;
|
ViewController* ViewController::sInstance = nullptr;
|
||||||
|
@ -54,7 +55,8 @@ ViewController::ViewController(
|
||||||
mWrappedViews(false),
|
mWrappedViews(false),
|
||||||
mFadeOpacity(0),
|
mFadeOpacity(0),
|
||||||
mCancelledAnimation(false),
|
mCancelledAnimation(false),
|
||||||
mLockInput(false)
|
mLockInput(false),
|
||||||
|
mGameToLaunch(nullptr)
|
||||||
{
|
{
|
||||||
mState.viewing = NOTHING;
|
mState.viewing = NOTHING;
|
||||||
}
|
}
|
||||||
|
@ -172,6 +174,11 @@ void ViewController::restoreViewPosition()
|
||||||
|
|
||||||
void ViewController::goToSystemView(SystemData* system, bool playTransition)
|
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.
|
// Restore the X position for the view, if it was previously moved.
|
||||||
if (mWrappedViews)
|
if (mWrappedViews)
|
||||||
restoreViewPosition();
|
restoreViewPosition();
|
||||||
|
@ -198,11 +205,33 @@ void ViewController::goToSystemView(SystemData* system, bool playTransition)
|
||||||
mCurrentView->setRenderView(true);
|
mCurrentView->setRenderView(true);
|
||||||
PowerSaver::setState(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();
|
playViewTransition();
|
||||||
else
|
else
|
||||||
playViewTransition(true);
|
playViewTransition(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewController::goToNextGameList()
|
void ViewController::goToNextGameList()
|
||||||
|
@ -306,14 +335,29 @@ void ViewController::goToGameList(SystemData* system)
|
||||||
mWrappedViews = true;
|
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.viewing = GAME_LIST;
|
||||||
mState.system = system;
|
mState.system = system;
|
||||||
|
|
||||||
if (mCurrentView)
|
if (mCurrentView)
|
||||||
mCurrentView->onHide();
|
mCurrentView->onHide();
|
||||||
|
|
||||||
mCurrentView = getGameListView(system);
|
|
||||||
|
|
||||||
if (mCurrentView) {
|
if (mCurrentView) {
|
||||||
mCurrentView->onShow();
|
mCurrentView->onShow();
|
||||||
mCurrentView->setRenderView(true);
|
mCurrentView->setRenderView(true);
|
||||||
|
@ -387,7 +431,7 @@ void ViewController::onFileChanged(FileData* file, bool reloadGameList)
|
||||||
it->second->onFileChanged(file, reloadGameList);
|
it->second->onFileChanged(file, reloadGameList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewController::launch(FileData* game, Vector3f center)
|
void ViewController::launch(FileData* game)
|
||||||
{
|
{
|
||||||
if (game->getType() != GAME) {
|
if (game->getType() != GAME) {
|
||||||
LOG(LogError) << "tried to launch something that isn't a 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.
|
stopAnimation(1); // Make sure the fade in isn't still playing.
|
||||||
mWindow->stopInfoPopup(); // Make sure we disable any existing info popup.
|
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
|
// 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,
|
// 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);
|
mCurrentView->update(deltaTime);
|
||||||
|
|
||||||
updateSelf(deltaTime);
|
updateSelf(deltaTime);
|
||||||
|
|
||||||
|
if (mGameToLaunch) {
|
||||||
|
launch(mGameToLaunch);
|
||||||
|
mGameToLaunch = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewController::render(const Transform4x4f& parentTrans)
|
void ViewController::render(const Transform4x4f& parentTrans)
|
||||||
|
|
|
@ -59,9 +59,8 @@ public:
|
||||||
void stopScrolling();
|
void stopScrolling();
|
||||||
|
|
||||||
void onFileChanged(FileData* file, bool reloadGameList);
|
void onFileChanged(FileData* file, bool reloadGameList);
|
||||||
|
void triggerGameLaunch(FileData* game) { mGameToLaunch = game; mLockInput = true; };
|
||||||
void launch(FileData* game, Vector3f centerCameraOn =
|
bool getGameLaunchTriggered() { return (mGameToLaunch != nullptr); };
|
||||||
Vector3f(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f, 0));
|
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void update(int deltaTime) override;
|
void update(int deltaTime) override;
|
||||||
|
@ -109,6 +108,8 @@ private:
|
||||||
ViewController(Window* window);
|
ViewController(Window* window);
|
||||||
static ViewController* sInstance;
|
static ViewController* sInstance;
|
||||||
|
|
||||||
|
void launch(FileData* game);
|
||||||
|
|
||||||
void playViewTransition(bool instant = false);
|
void playViewTransition(bool instant = false);
|
||||||
int getSystemId(SystemData* system);
|
int getSystemId(SystemData* system);
|
||||||
// Restore view position if it was moved during wrap around.
|
// Restore view position if it was moved during wrap around.
|
||||||
|
@ -125,6 +126,7 @@ private:
|
||||||
float mFadeOpacity;
|
float mFadeOpacity;
|
||||||
bool mCancelledAnimation; // Needed only for the Fade transition style.
|
bool mCancelledAnimation; // Needed only for the Fade transition style.
|
||||||
bool mLockInput;
|
bool mLockInput;
|
||||||
|
FileData* mGameToLaunch;
|
||||||
|
|
||||||
State mState;
|
State mState;
|
||||||
};
|
};
|
||||||
|
|
|
@ -189,7 +189,7 @@ std::string BasicGameListView::getQuickSystemSelectLeftButton()
|
||||||
|
|
||||||
void BasicGameListView::launch(FileData* game)
|
void BasicGameListView::launch(FileData* game)
|
||||||
{
|
{
|
||||||
ViewController::get()->launch(game);
|
ViewController::get()->triggerGameLaunch(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicGameListView::remove(FileData *game, bool deleteFile)
|
void BasicGameListView::remove(FileData *game, bool deleteFile)
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include "SystemData.h"
|
#include "SystemData.h"
|
||||||
|
|
||||||
#define FADE_IN_START_OPACITY 0.5f
|
#define FADE_IN_START_OPACITY 0.5f
|
||||||
#define FADE_IN_TIME 300
|
#define FADE_IN_TIME 650
|
||||||
|
|
||||||
DetailedGameListView::DetailedGameListView(
|
DetailedGameListView::DetailedGameListView(
|
||||||
Window* window,
|
Window* window,
|
||||||
|
@ -435,11 +435,7 @@ void DetailedGameListView::updateInfoPanel()
|
||||||
|
|
||||||
void DetailedGameListView::launch(FileData* game)
|
void DetailedGameListView::launch(FileData* game)
|
||||||
{
|
{
|
||||||
Vector3f target(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f, 0);
|
ViewController::get()->triggerGameLaunch(game);
|
||||||
if (mImage.hasImage())
|
|
||||||
target = Vector3f(mImage.getCenter().x(), mImage.getCenter().y(), 0);
|
|
||||||
|
|
||||||
ViewController::get()->launch(game, target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<TextComponent*> DetailedGameListView::getMDLabels()
|
std::vector<TextComponent*> DetailedGameListView::getMDLabels()
|
||||||
|
@ -470,6 +466,15 @@ std::vector<GuiComponent*> DetailedGameListView::getMDValues()
|
||||||
return ret;
|
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()
|
void DetailedGameListView::onShow()
|
||||||
{
|
{
|
||||||
mLastUpdated = nullptr;
|
mLastUpdated = nullptr;
|
||||||
|
|
|
@ -24,6 +24,9 @@ public:
|
||||||
virtual const char* getName() const override { return "detailed"; }
|
virtual const char* getName() const override { return "detailed"; }
|
||||||
virtual void launch(FileData* game) override;
|
virtual void launch(FileData* game) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void update(int deltaTime) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateInfoPanel();
|
void updateInfoPanel();
|
||||||
|
|
||||||
|
|
|
@ -533,24 +533,7 @@ void GridGameListView::addPlaceholder(FileData* firstEntry)
|
||||||
|
|
||||||
void GridGameListView::launch(FileData* game)
|
void GridGameListView::launch(FileData* game)
|
||||||
{
|
{
|
||||||
float screenWidth = (float) Renderer::getScreenWidth();
|
ViewController::get()->triggerGameLaunch(game);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridGameListView::remove(FileData *game, bool deleteFile)
|
void GridGameListView::remove(FileData *game, bool deleteFile)
|
||||||
|
|
|
@ -478,38 +478,7 @@ void VideoGameListView::updateInfoPanel()
|
||||||
|
|
||||||
void VideoGameListView::launch(FileData* game)
|
void VideoGameListView::launch(FileData* game)
|
||||||
{
|
{
|
||||||
float screenWidth = static_cast<float>(Renderer::getScreenWidth());
|
ViewController::get()->triggerGameLaunch(game);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<TextComponent*> VideoGameListView::getMDLabels()
|
std::vector<TextComponent*> VideoGameListView::getMDLabels()
|
||||||
|
@ -549,6 +518,9 @@ void VideoGameListView::update(int deltaTime)
|
||||||
|
|
||||||
BasicGameListView::update(deltaTime);
|
BasicGameListView::update(deltaTime);
|
||||||
mVideo->update(deltaTime);
|
mVideo->update(deltaTime);
|
||||||
|
|
||||||
|
if (ViewController::get()->getGameLaunchTriggered() && mVideo->isAnimationPlaying(0))
|
||||||
|
mVideo->finishAnimation(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoGameListView::onShow()
|
void VideoGameListView::onShow()
|
||||||
|
|
Loading…
Reference in a new issue