mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
The application startup can now be aborted via an OS signal or using the configured keyboard quit shortcut.
This commit is contained in:
parent
1e31423f3f
commit
cf8ce151dd
|
@ -15,6 +15,7 @@
|
|||
#include "FileFilterIndex.h"
|
||||
#include "FileSorts.h"
|
||||
#include "GamelistFileParser.h"
|
||||
#include "InputManager.h"
|
||||
#include "Log.h"
|
||||
#include "Settings.h"
|
||||
#include "ThemeData.h"
|
||||
|
@ -32,9 +33,6 @@
|
|||
#include <pugixml.hpp>
|
||||
#include <random>
|
||||
|
||||
std::vector<SystemData*> SystemData::sSystemVector;
|
||||
std::unique_ptr<FindRules> SystemData::sFindRules;
|
||||
|
||||
FindRules::FindRules()
|
||||
{
|
||||
LOG(LogInfo) << "Loading emulator find rules...";
|
||||
|
@ -544,7 +542,13 @@ bool SystemData::loadConfig()
|
|||
system = system.next_sibling("system")) {
|
||||
// Poll events so that the OS doesn't think the application is hanging on startup,
|
||||
// this is required as the main application loop hasn't started yet.
|
||||
while (SDL_PollEvent(&event)) {};
|
||||
while (SDL_PollEvent(&event)) {
|
||||
InputManager::getInstance().parseEvent(event);
|
||||
if (event.type == SDL_QUIT) {
|
||||
sStartupExitSignal = true;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
std::string name;
|
||||
std::string fullname;
|
||||
|
|
|
@ -114,8 +114,9 @@ public:
|
|||
// Generates the game system directories and information files based on es_systems.xml.
|
||||
static bool createSystemDirectories();
|
||||
|
||||
static std::vector<SystemData*> sSystemVector;
|
||||
static std::unique_ptr<FindRules> sFindRules;
|
||||
static inline std::vector<SystemData*> sSystemVector;
|
||||
static inline std::unique_ptr<FindRules> sFindRules;
|
||||
static inline bool sStartupExitSignal {false};
|
||||
|
||||
const bool isCollection() const { return mIsCollectionSystem; }
|
||||
const bool isCustomCollection() const { return mIsCustomCollectionSystem; }
|
||||
|
|
|
@ -704,6 +704,7 @@ int main(int argc, char* argv[])
|
|||
ThemeData::populateThemeSets();
|
||||
loadSystemsReturnCode loadSystemsStatus {loadSystemConfigFile()};
|
||||
|
||||
if (!SystemData::sStartupExitSignal) {
|
||||
if (loadSystemsStatus) {
|
||||
// If there was an issue parsing the es_systems.xml file, display an error message.
|
||||
// If there were no game files found, give the option to the user to quit or to
|
||||
|
@ -717,7 +718,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
}
|
||||
|
||||
// Check if any of the enabled systems has an invalid alternative emulator entry,
|
||||
// Check if any of the enabled systems have an invalid alternative emulator entry,
|
||||
// which means that a label is present in the gamelist.xml file which is not matching
|
||||
// any command tag in es_systems.xml.
|
||||
for (auto system : SystemData::sSystemVector) {
|
||||
|
@ -730,16 +731,17 @@ int main(int argc, char* argv[])
|
|||
// Don't generate controller events while we're loading.
|
||||
SDL_GameControllerEventState(SDL_DISABLE);
|
||||
|
||||
// Preload what we can right away instead of waiting for the user to select it.
|
||||
// This makes for no delays when accessing content, but a longer startup time.
|
||||
// Preload system view and all gamelist views.
|
||||
ViewController::getInstance()->preload();
|
||||
}
|
||||
|
||||
if (!SystemData::sStartupExitSignal) {
|
||||
if (loadSystemsStatus == loadSystemsReturnCode::LOADING_OK) {
|
||||
LOG(LogInfo) << "Finished loading theme set \"" << ThemeData::getCurrentThemeSetName()
|
||||
<< "\"";
|
||||
}
|
||||
|
||||
// Open the input configuration GUI if the flag to force this was passed from the command line.
|
||||
// Open the input configuration GUI if the force flag was passed from the command line.
|
||||
if (!loadSystemsStatus) {
|
||||
if (forceInputConfig) {
|
||||
window->pushGui(new GuiDetectDevice(
|
||||
|
@ -763,11 +765,17 @@ int main(int argc, char* argv[])
|
|||
|
||||
// Main application loop.
|
||||
|
||||
if (!SystemData::sStartupExitSignal) {
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
emscripten_set_main_loop(&applicationLoop, 0, 1);
|
||||
#else
|
||||
applicationLoop();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else {
|
||||
LOG(LogInfo) << "Exit signal received, aborting application startup";
|
||||
}
|
||||
|
||||
while (window->peekGui() != ViewController::getInstance())
|
||||
delete window->peekGui();
|
||||
|
|
|
@ -1101,7 +1101,13 @@ void ViewController::preload()
|
|||
it != SystemData::sSystemVector.cend(); ++it) {
|
||||
// Poll events so that the OS doesn't think the application is hanging on startup,
|
||||
// this is required as the main application loop hasn't started yet.
|
||||
while (SDL_PollEvent(&event)) {};
|
||||
while (SDL_PollEvent(&event)) {
|
||||
InputManager::getInstance().parseEvent(event);
|
||||
if (event.type == SDL_QUIT) {
|
||||
SystemData::sStartupExitSignal = true;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
const std::string entryType {(*it)->isCustomCollection() ? "custom collection" : "system"};
|
||||
LOG(LogDebug) << "ViewController::preload(): Populating gamelist for " << entryType << " \""
|
||||
|
|
Loading…
Reference in a new issue