mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
Changed the game launch state to be kept in Window instead of ViewController
This commit is contained in:
parent
e1322d711b
commit
e3387c9016
|
@ -915,6 +915,12 @@ void FileData::launchGame()
|
|||
|
||||
const std::string fileName {baseName + Utils::FileSystem::getExtension(romPath)};
|
||||
const std::string esPath {Utils::FileSystem::getExePath()};
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
// On Android we always run in the background, although the logic is a bit different
|
||||
// as we don't need to wake up the application manually.
|
||||
bool runInBackground {true};
|
||||
#else
|
||||
bool runInBackground {false};
|
||||
|
||||
// In addition to the global RunInBackground setting it's possible to define this flag
|
||||
|
@ -933,6 +939,7 @@ void FileData::launchGame()
|
|||
// The global setting always applies.
|
||||
if (Settings::getInstance()->getBool("RunInBackground"))
|
||||
runInBackground = true;
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN64)
|
||||
// Whether to parse .desktop files on Unix or open apps or alias files on macOS.
|
||||
|
@ -1893,8 +1900,7 @@ returnValue = Utils::Platform::launchGameUnix(command, startDirectory, runInBack
|
|||
getSourceFileData()->getSystem()->getFullName());
|
||||
}
|
||||
else {
|
||||
std::vector<std::string>& gameEndParams {
|
||||
ViewController::getInstance()->getGameEndEventParams()};
|
||||
std::vector<std::string>& gameEndParams {window->getGameEndEventParams()};
|
||||
gameEndParams.emplace_back("game-end");
|
||||
gameEndParams.emplace_back(romPath);
|
||||
gameEndParams.emplace_back(getSourceFileData()->metadata.get("name"));
|
||||
|
|
|
@ -1109,7 +1109,10 @@ bool ViewController::input(InputConfig* config, Input input)
|
|||
// If we're in this state and then register some input, it means that the user is back in ES-DE.
|
||||
// Therefore unset the game launch flag and update all the GUI components. This will re-enable
|
||||
// the video player and scrolling of game names and game descriptions as well as letting the
|
||||
// screensaver start on schedule.
|
||||
// screensaver start on schedule. On Android the onResume() method will call the native onResume
|
||||
// function which will perform the same steps as shown below (on Android we always keep running
|
||||
// when launching games).
|
||||
#if !defined(__ANDROID__)
|
||||
if (mWindow->getGameLaunchedState()) {
|
||||
mWindow->setAllowTextScrolling(true);
|
||||
mWindow->setAllowFileAnimation(true);
|
||||
|
@ -1119,13 +1122,14 @@ bool ViewController::input(InputConfig* config, Input input)
|
|||
if (config->isMappedTo("a", input) && input.value != 0)
|
||||
return true;
|
||||
// Trigger the game-end event.
|
||||
if (mGameEndEventParams.size() == 5) {
|
||||
Scripting::fireEvent(mGameEndEventParams[0], mGameEndEventParams[1],
|
||||
mGameEndEventParams[2], mGameEndEventParams[3],
|
||||
mGameEndEventParams[4]);
|
||||
mGameEndEventParams.clear();
|
||||
auto& eventParams = mWindow->getGameEndEventParams();
|
||||
if (eventParams.size() == 5) {
|
||||
Scripting::fireEvent(eventParams[0], eventParams[1], eventParams[2], eventParams[3],
|
||||
eventParams[4]);
|
||||
eventParams.clear();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Open the main menu.
|
||||
if (!(UIModeController::getInstance()->isUIModeKid() &&
|
||||
|
|
|
@ -93,7 +93,6 @@ public:
|
|||
mWindow->setBlockInput(true);
|
||||
};
|
||||
const bool getGameLaunchTriggered() { return (mGameToLaunch != nullptr); }
|
||||
std::vector<std::string>& getGameEndEventParams() { return mGameEndEventParams; }
|
||||
|
||||
bool input(InputConfig* config, Input input) override;
|
||||
void update(int deltaTime) override;
|
||||
|
@ -184,7 +183,6 @@ private:
|
|||
std::shared_ptr<SystemView> mSystemListView;
|
||||
ViewTransitionAnimation mLastTransitionAnim;
|
||||
|
||||
std::vector<std::string> mGameEndEventParams;
|
||||
FileData* mGameToLaunch;
|
||||
State mState;
|
||||
|
||||
|
|
|
@ -156,6 +156,7 @@ public:
|
|||
void invalidateCachedBackground();
|
||||
bool isInvalidatingCachedBackground() { return mInvalidateCacheTimer > 0; }
|
||||
|
||||
std::vector<std::string>& getGameEndEventParams() { return mGameEndEventParams; }
|
||||
bool getGameLaunchedState() { return mGameLaunchedState; }
|
||||
void setAllowTextScrolling(bool value) { mAllowTextScrolling = value; }
|
||||
bool getAllowTextScrolling() { return mAllowTextScrolling; }
|
||||
|
@ -207,6 +208,7 @@ private:
|
|||
std::queue<std::pair<std::string, int>> mInfoPopupQueue;
|
||||
std::shared_ptr<TextureResource> mPostprocessedBackground;
|
||||
|
||||
std::vector<std::string> mGameEndEventParams;
|
||||
std::string mListScrollText;
|
||||
std::shared_ptr<Font> mListScrollFont;
|
||||
float mListScrollOpacity;
|
||||
|
@ -223,9 +225,9 @@ private:
|
|||
bool mRenderMediaViewer;
|
||||
bool mRenderLaunchScreen;
|
||||
bool mRenderPDFViewer;
|
||||
bool mGameLaunchedState;
|
||||
bool mAllowTextScrolling;
|
||||
bool mAllowFileAnimation;
|
||||
std::atomic<bool> mGameLaunchedState;
|
||||
std::atomic<bool> mAllowTextScrolling;
|
||||
std::atomic<bool> mAllowFileAnimation;
|
||||
bool mCachedBackground;
|
||||
bool mInvalidatedCachedBackground;
|
||||
bool mInitiateCacheTimer;
|
||||
|
|
Loading…
Reference in a new issue