aboutsummaryrefslogtreecommitdiff
path: root/base/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'base/main.cpp')
-rw-r--r--base/main.cpp62
1 files changed, 53 insertions, 9 deletions
diff --git a/base/main.cpp b/base/main.cpp
index 0f5ebc7845..6b6868b78a 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -66,6 +66,13 @@
#endif
#include "backends/keymapper/keymapper.h"
+#ifdef USE_LIBCURL
+#include "backends/cloud/cloudmanager.h"
+#include "backends/networking/curl/connectionmanager.h"
+#endif
+#ifdef USE_SDL_NET
+#include "backends/networking/sdl_net/localwebserver.h"
+#endif
#if defined(_WIN32_WCE)
#include "backends/platform/wince/CELauncherDialog.h"
@@ -75,6 +82,9 @@
#include "gui/launcher.h"
#endif
+#ifdef USE_UPDATES
+#include "gui/updates-dialog.h"
+#endif
static bool launcherDialog() {
@@ -148,12 +158,24 @@ static Common::Error runGame(const EnginePlugin *plugin, OSystem &system, const
#endif
// Verify that the game path refers to an actual directory
- if (!(dir.exists() && dir.isDirectory()))
+ if (!dir.exists()) {
+ err = Common::kPathDoesNotExist;
+ } else if (!dir.isDirectory()) {
err = Common::kPathNotDirectory;
+ }
// Create the game engine
- if (err.getCode() == Common::kNoError)
+ if (err.getCode() == Common::kNoError) {
+ // Set default values for all of the custom engine options
+ // Appareantly some engines query them in their constructor, thus we
+ // need to set this up before instance creation.
+ const ExtraGuiOptions engineOptions = (*plugin)->getExtraGuiOptions(Common::String());
+ for (uint i = 0; i < engineOptions.size(); i++) {
+ ConfMan.registerDefault(engineOptions[i].configOption, engineOptions[i].defaultState);
+ }
+
err = (*plugin)->createInstance(&system, &engine);
+ }
// Check for errors
if (!engine || err.getCode() != Common::kNoError) {
@@ -231,12 +253,6 @@ static Common::Error runGame(const EnginePlugin *plugin, OSystem &system, const
// Initialize any game-specific keymaps
engine->initKeymap();
- // Set default values for all of the custom engine options
- const ExtraGuiOptions engineOptions = (*plugin)->getExtraGuiOptions(Common::String());
- for (uint i = 0; i < engineOptions.size(); i++) {
- ConfMan.registerDefault(engineOptions[i].configOption, engineOptions[i].defaultState);
- }
-
// Inform backend that the engine is about to be run
system.engineInit();
@@ -379,7 +395,12 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
if (settings.contains("debugflags")) {
specialDebug = settings["debugflags"];
settings.erase("debugflags");
- }
+ } else if (ConfMan.hasKey("debugflags"))
+ specialDebug = ConfMan.get("debugflags");
+
+ if (settings.contains("debug-channels-only"))
+ gDebugChannelsOnly = true;
+
PluginManager::instance().init();
PluginManager::instance().loadAllPlugins(); // load plugins for cached plugin manager
@@ -455,6 +476,18 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
// Now as the event manager is created, setup the keymapper
setupKeymapper(system);
+#ifdef USE_UPDATES
+ if (!ConfMan.hasKey("updates_check")) {
+ GUI::UpdatesDialog dlg;
+ dlg.runModal();
+ }
+#endif
+
+#ifdef USE_LIBCURL
+ CloudMan.init();
+ CloudMan.syncSaves();
+#endif
+
// Unless a game was specified, show the launcher dialog
if (0 == ConfMan.getActiveDomain())
launcherDialog();
@@ -552,6 +585,9 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
PluginManager::instance().loadAllPlugins(); // only for cached manager
} else {
GUI::displayErrorDialog(_("Could not find any engine capable of running the selected game"));
+
+ // Clear the active domain
+ ConfMan.setActiveDomain("");
}
// reset the graphics to default
@@ -560,6 +596,14 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
launcherDialog();
}
}
+#ifdef USE_SDL_NET
+ Networking::LocalWebserver::destroy();
+#endif
+#ifdef USE_LIBCURL
+ Networking::ConnectionManager::destroy();
+ //I think it's important to destroy it after ConnectionManager
+ Cloud::CloudManager::destroy();
+#endif
PluginManager::instance().unloadAllPlugins();
PluginManager::destroy();
GUI::GuiManager::destroy();