mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Added a proper function to check whether to keep running in the background while a game is launched.
This commit is contained in:
parent
ad04963431
commit
ec33d8a612
|
@ -15,6 +15,7 @@
|
||||||
#include "utils/StringUtil.h"
|
#include "utils/StringUtil.h"
|
||||||
#include "utils/TimeUtil.h"
|
#include "utils/TimeUtil.h"
|
||||||
#include "views/UIModeController.h"
|
#include "views/UIModeController.h"
|
||||||
|
#include "views/ViewController.h"
|
||||||
#include "AudioManager.h"
|
#include "AudioManager.h"
|
||||||
#include "CollectionSystemsManager.h"
|
#include "CollectionSystemsManager.h"
|
||||||
#include "FileFilterIndex.h"
|
#include "FileFilterIndex.h"
|
||||||
|
@ -953,19 +954,13 @@ void FileData::launchGame(Window* window)
|
||||||
LOG(LogInfo) << "Expanded emulator launch command:";
|
LOG(LogInfo) << "Expanded emulator launch command:";
|
||||||
|
|
||||||
LOG(LogInfo) << command;
|
LOG(LogInfo) << command;
|
||||||
|
// Possibly keep ES-DE running in the background while the game is launched.
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
if (mSystem->hasPlatformId(PlatformIds::VALVE_STEAM) ||
|
returnValue = launchGameWindows(Utils::String::stringToWideString(command),
|
||||||
Settings::getInstance()->getBool("RunInBackground"))
|
ViewController::get()->runInBackground(mSystem));
|
||||||
returnValue = launchGameWindows(Utils::String::stringToWideString(command), true);
|
|
||||||
else
|
|
||||||
returnValue = launchGameWindows(Utils::String::stringToWideString(command), false);
|
|
||||||
#else
|
#else
|
||||||
if (mSystem->hasPlatformId(PlatformIds::VALVE_STEAM))
|
returnValue = launchGameUnix(command, ViewController::get()->runInBackground(mSystem));
|
||||||
returnValue = launchGameUnix(command, true);
|
|
||||||
else
|
|
||||||
returnValue = launchGameUnix(command, false);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Notify the user in case of a failed game launch using a popup window.
|
// Notify the user in case of a failed game launch using a popup window.
|
||||||
if (returnValue != 0) {
|
if (returnValue != 0) {
|
||||||
LOG(LogWarning) << "...launch terminated with nonzero return value " << returnValue;
|
LOG(LogWarning) << "...launch terminated with nonzero return value " << returnValue;
|
||||||
|
@ -978,21 +973,20 @@ void FileData::launchGame(Window* window)
|
||||||
else {
|
else {
|
||||||
// Stop showing the game launch notification.
|
// Stop showing the game launch notification.
|
||||||
window->stopInfoPopup();
|
window->stopInfoPopup();
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
// If starting a Steam game or if the "RunInBackground" setting has been enabled,
|
// For some game systems or if the "RunInBackground" setting has been enabled, keep
|
||||||
// then keep ES-DE running while the game is launched. This pauses any video and keeps
|
// ES-DE running while the game is launched. This pauses any video and keeps the
|
||||||
// the screensaver from getting activated.
|
// screensaver from getting activated.
|
||||||
if (mSystem->hasPlatformId(PlatformIds::VALVE_STEAM) ||
|
if (ViewController::get()->runInBackground(mSystem))
|
||||||
Settings::getInstance()->getBool("RunInBackground"))
|
|
||||||
window->setLaunchedGame();
|
window->setLaunchedGame();
|
||||||
else
|
else
|
||||||
// Normalize deltaTime so that the screensaver does not start immediately
|
// Normalize deltaTime so that the screensaver does not start immediately
|
||||||
// when returning from the game.
|
// when returning from the game.
|
||||||
window->normalizeNextUpdate();
|
window->normalizeNextUpdate();
|
||||||
#else
|
#else
|
||||||
// If starting a Steam game, then keep ES-DE running while the game is launched.
|
// For some game systems we need to keep ES-DE running while the game is launched.
|
||||||
// This pauses any video and keeps the screensaver from getting activated.
|
// This pauses any video and keeps the screensaver from getting activated.
|
||||||
if (mSystem->hasPlatformId(PlatformIds::VALVE_STEAM))
|
if (ViewController::get()->runInBackground(mSystem))
|
||||||
window->setLaunchedGame();
|
window->setLaunchedGame();
|
||||||
// Normalize deltaTime so that the screensaver does not start immediately
|
// Normalize deltaTime so that the screensaver does not start immediately
|
||||||
// when returning from the game.
|
// when returning from the game.
|
||||||
|
|
|
@ -614,6 +614,22 @@ void ViewController::onFileChanged(FileData* file, bool reloadGameList)
|
||||||
it->second->onFileChanged(file, reloadGameList);
|
it->second->onFileChanged(file, reloadGameList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ViewController::runInBackground(SystemData* system)
|
||||||
|
{
|
||||||
|
#if defined(_WIN64)
|
||||||
|
if (system->hasPlatformId(PlatformIds::VALVE_STEAM) ||
|
||||||
|
Settings::getInstance()->getBool("RunInBackground"))
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
if (system->hasPlatformId(PlatformIds::VALVE_STEAM))
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void ViewController::launch(FileData* game)
|
void ViewController::launch(FileData* game)
|
||||||
{
|
{
|
||||||
if (game->getType() != GAME) {
|
if (game->getType() != GAME) {
|
||||||
|
|
|
@ -113,6 +113,9 @@ public:
|
||||||
std::shared_ptr<SystemView> getSystemListView();
|
std::shared_ptr<SystemView> getSystemListView();
|
||||||
void removeGameListView(SystemData* system);
|
void removeGameListView(SystemData* system);
|
||||||
|
|
||||||
|
// Whether to run in the background while a game is launched.
|
||||||
|
bool runInBackground(SystemData* system);
|
||||||
|
|
||||||
static const std::string FAVORITE_CHAR;
|
static const std::string FAVORITE_CHAR;
|
||||||
static const std::string FOLDER_CHAR;
|
static const std::string FOLDER_CHAR;
|
||||||
static const std::string TICKMARK_CHAR;
|
static const std::string TICKMARK_CHAR;
|
||||||
|
|
Loading…
Reference in a new issue