ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

main.cpp

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00031 // FIXME: Avoid using printf
00032 #define FORBIDDEN_SYMBOL_EXCEPTION_printf
00033 
00034 #include "engines/engine.h"
00035 #include "engines/metaengine.h"
00036 #include "base/commandLine.h"
00037 #include "base/plugins.h"
00038 #include "base/version.h"
00039 
00040 #include "common/archive.h"
00041 #include "common/config-manager.h"
00042 #include "common/debug.h"
00043 #include "common/debug-channels.h" /* for debug manager */
00044 #include "common/events.h"
00045 #include "gui/EventRecorder.h"
00046 #include "common/fs.h"
00047 #ifdef ENABLE_EVENTRECORDER
00048 #include "common/recorderfile.h"
00049 #endif
00050 #include "common/system.h"
00051 #include "common/textconsole.h"
00052 #include "common/tokenizer.h"
00053 #include "common/translation.h"
00054 #include "common/osd_message_queue.h"
00055 
00056 #include "gui/gui-manager.h"
00057 #include "gui/error.h"
00058 
00059 #include "audio/mididrv.h"
00060 #include "audio/musicplugin.h"  /* for music manager */
00061 
00062 #include "graphics/cursorman.h"
00063 #include "graphics/fontman.h"
00064 #include "graphics/yuv_to_rgb.h"
00065 #ifdef USE_FREETYPE2
00066 #include "graphics/fonts/ttf.h"
00067 #endif
00068 
00069 #include "backends/keymapper/keymapper.h"
00070 #ifdef USE_CLOUD
00071 #ifdef USE_LIBCURL
00072 #include "backends/cloud/cloudmanager.h"
00073 #include "backends/networking/curl/connectionmanager.h"
00074 #endif
00075 #ifdef USE_SDL_NET
00076 #include "backends/networking/sdl_net/localwebserver.h"
00077 #endif
00078 #endif
00079 
00080 #if defined(_WIN32_WCE)
00081 #include "backends/platform/wince/CELauncherDialog.h"
00082 #elif defined(__DC__)
00083 #include "backends/platform/dc/DCLauncherDialog.h"
00084 #else
00085 #include "gui/launcher.h"
00086 #endif
00087 
00088 #ifdef USE_UPDATES
00089 #include "gui/updates-dialog.h"
00090 #endif
00091 
00092 static bool launcherDialog() {
00093 
00094     // Discard any command line options. Those that affect the graphics
00095     // mode and the others (like bootparam etc.) should not
00096     // blindly be passed to the first game launched from the launcher.
00097     ConfMan.getDomain(Common::ConfigManager::kTransientDomain)->clear();
00098 
00099 #if defined(_WIN32_WCE)
00100     CELauncherDialog dlg;
00101 #elif defined(__DC__)
00102     DCLauncherDialog dlg;
00103 #else
00104     GUI::LauncherDialog dlg;
00105 #endif
00106     return (dlg.runModal() != -1);
00107 }
00108 
00109 static const Plugin *detectPlugin() {
00110     const Plugin *plugin = nullptr;
00111 
00112     // Make sure the gameid is set in the config manager, and that it is lowercase.
00113     Common::String gameid(ConfMan.getActiveDomainName());
00114     assert(!gameid.empty());
00115     if (ConfMan.hasKey("gameid")) {
00116         gameid = ConfMan.get("gameid");
00117 
00118         // Set last selected game, that the game will be highlighted
00119         // on RTL
00120         ConfMan.set("lastselectedgame", ConfMan.getActiveDomainName(), Common::ConfigManager::kApplicationDomain);
00121         ConfMan.flushToDisk();
00122     }
00123 
00124     gameid.toLowercase();
00125     ConfMan.set("gameid", gameid);
00126 
00127     // Query the plugins and find one that will handle the specified gameid
00128     printf("User picked target '%s' (gameid '%s')...\n", ConfMan.getActiveDomainName().c_str(), gameid.c_str());
00129     printf("  Looking for a plugin supporting this gameid... ");
00130 
00131     PlainGameDescriptor game = EngineMan.findGame(gameid, &plugin);
00132 
00133     if (plugin == 0) {
00134         printf("failed\n");
00135         warning("%s is an invalid gameid. Use the --list-games option to list supported gameid", gameid.c_str());
00136     } else {
00137         printf("%s\n  Starting '%s'\n", plugin->getName(), game.description);
00138     }
00139 
00140     return plugin;
00141 }
00142 
00143 // TODO: specify the possible return values here
00144 static Common::Error runGame(const Plugin *plugin, OSystem &system, const Common::String &edebuglevels) {
00145     // Determine the game data path, for validation and error messages
00146     Common::FSNode dir(ConfMan.get("path"));
00147     Common::Error err = Common::kNoError;
00148     Engine *engine = 0;
00149 
00150 // Disabled in ResidualVM:
00151 #if 0//defined(SDL_BACKEND) && defined(USE_OPENGL) && defined(USE_RGB_COLOR)
00152     // HACK: We set up the requested graphics mode setting here to allow the
00153     // backend to switch from Surface SDL to OpenGL if necessary. This is
00154     // needed because otherwise the g_system->getSupportedFormats might return
00155     // bad values.
00156     g_system->beginGFXTransaction();
00157         g_system->setGraphicsMode(ConfMan.get("gfx_mode").c_str());
00158     if (g_system->endGFXTransaction() != OSystem::kTransactionSuccess) {
00159         warning("Switching graphics mode to '%s' failed", ConfMan.get("gfx_mode").c_str());
00160         return Common::kUnknownError;
00161     }
00162 #endif
00163 
00164     // Verify that the game path refers to an actual directory
00165         if (!dir.exists()) {
00166         err = Common::kPathDoesNotExist;
00167         } else if (!dir.isDirectory()) {
00168         err = Common::kPathNotDirectory;
00169         }
00170 
00171     // Create the game engine
00172     if (err.getCode() == Common::kNoError) {
00173         const MetaEngine &metaEngine = plugin->get<MetaEngine>();
00174         // Set default values for all of the custom engine options
00175         // Apparently some engines query them in their constructor, thus we
00176         // need to set this up before instance creation.
00177         const ExtraGuiOptions engineOptions = metaEngine.getExtraGuiOptions(Common::String());
00178         for (uint i = 0; i < engineOptions.size(); i++) {
00179             ConfMan.registerDefault(engineOptions[i].configOption, engineOptions[i].defaultState);
00180         }
00181 
00182         err = metaEngine.createInstance(&system, &engine);
00183     }
00184 
00185     // Check for errors
00186     if (!engine || err.getCode() != Common::kNoError) {
00187 
00188         // Print a warning; note that scummvm_main will also
00189         // display an error dialog, so we don't have to do this here.
00190         warning("%s failed to instantiate engine: %s (target '%s', path '%s')",
00191             plugin->getName(),
00192             err.getDesc().c_str(),
00193             ConfMan.getActiveDomainName().c_str(),
00194             dir.getPath().c_str()
00195             );
00196 
00197         // If a temporary target failed to launch, remove it from the configuration manager
00198         // so it not visible in the launcher.
00199         // Temporary targets are created when starting games from the command line using the game id.
00200         if (ConfMan.hasKey("id_came_from_command_line")) {
00201             ConfMan.removeGameDomain(ConfMan.getActiveDomainName().c_str());
00202         }
00203 
00204         return err;
00205     }
00206 
00207     // Set the window caption to the game name
00208     Common::String caption(ConfMan.get("description"));
00209 
00210     if (caption.empty()) {
00211         PlainGameDescriptor game = EngineMan.findGame(ConfMan.get("gameid"));
00212         if (game.description) {
00213             caption = game.description;
00214         }
00215     }
00216     if (caption.empty())
00217         caption = ConfMan.getActiveDomainName(); // Use the domain (=target) name
00218     if (!caption.empty())   {
00219         system.setWindowCaption(caption.c_str());
00220     }
00221 
00222     //
00223     // Setup various paths in the SearchManager
00224     //
00225 
00226     // Add the game path to the directory search list
00227     engine->initializePath(dir);
00228 
00229     // Add extrapath (if any) to the directory search list
00230     if (ConfMan.hasKey("extrapath")) {
00231         dir = Common::FSNode(ConfMan.get("extrapath"));
00232         SearchMan.addDirectory(dir.getPath(), dir);
00233     }
00234 
00235     // If a second extrapath is specified on the app domain level, add that as well.
00236     // However, since the default hasKey() and get() check the app domain level,
00237     // verify that it's not already there before adding it. The search manager will
00238     // check for that too, so this check is mostly to avoid a warning message.
00239     if (ConfMan.hasKey("extrapath", Common::ConfigManager::kApplicationDomain)) {
00240         Common::String extraPath = ConfMan.get("extrapath", Common::ConfigManager::kApplicationDomain);
00241         if (!SearchMan.hasArchive(extraPath)) {
00242             dir = Common::FSNode(extraPath);
00243             SearchMan.addDirectory(dir.getPath(), dir);
00244         }
00245     }
00246 
00247     // On creation the engine should have set up all debug levels so we can use
00248     // the command line arguments here
00249     Common::StringTokenizer tokenizer(edebuglevels, " ,");
00250     while (!tokenizer.empty()) {
00251         Common::String token = tokenizer.nextToken();
00252         if (token.equalsIgnoreCase("all"))
00253             DebugMan.enableAllDebugChannels();
00254         else if (!DebugMan.enableDebugChannel(token))
00255             warning(_("Engine does not support debug level '%s'"), token.c_str());
00256     }
00257 
00258 #ifdef USE_TRANSLATION
00259     Common::String previousLanguage = TransMan.getCurrentLanguage();
00260     if (ConfMan.hasKey("gui_use_game_language")
00261         && ConfMan.getBool("gui_use_game_language")
00262         && ConfMan.hasKey("language")) {
00263         TransMan.setLanguage(ConfMan.get("language"));
00264     }
00265 #endif
00266 
00267     // Initialize any game-specific keymaps
00268     engine->initKeymap();
00269 
00270     // Inform backend that the engine is about to be run
00271     system.engineInit();
00272 
00273     // Run the engine
00274     Common::Error result = engine->run();
00275 
00276     // Inform backend that the engine finished
00277     system.engineDone();
00278 
00279     // Clean up any game-specific keymaps
00280     engine->deinitKeymap();
00281 
00282     // Free up memory
00283     delete engine;
00284 
00285     // We clear all debug levels again even though the engine should do it
00286     DebugMan.clearAllDebugChannels();
00287 
00288     // Reset the file/directory mappings
00289     SearchMan.clear();
00290 
00291 #ifdef USE_TRANSLATION
00292     TransMan.setLanguage(previousLanguage);
00293 #endif
00294 
00295     // Return result (== 0 means no error)
00296     return result;
00297 }
00298 
00299 static void setupGraphics(OSystem &system) {
00300 
00301     system.beginGFXTransaction();
00302         // Set the user specified graphics mode (if any).
00303         system.setGraphicsMode(ConfMan.get("gfx_mode").c_str());
00304 
00305         system.initSize(320, 200);
00306         system.launcherInitSize(640, 480); //ResidualVM specific
00307 
00308         if (ConfMan.hasKey("aspect_ratio"))
00309             system.setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio"));
00310         if (ConfMan.hasKey("fullscreen"))
00311             system.setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
00312         if (ConfMan.hasKey("filtering"))
00313             system.setFeatureState(OSystem::kFeatureFilteringMode, ConfMan.getBool("filtering"));
00314         if (ConfMan.hasKey("stretch_mode"))
00315             system.setStretchMode(ConfMan.get("stretch_mode").c_str());
00316     system.endGFXTransaction();
00317 
00318     // When starting up launcher for the first time, the user might have specified
00319     // a --gui-theme option, to allow that option to be working, we need to initialize
00320     // GUI here.
00321     // FIXME: Find a nicer way to allow --gui-theme to be working
00322     GUI::GuiManager::instance();
00323 
00324     // Set initial window caption
00325     system.setWindowCaption(gScummVMFullVersion);
00326 
00327     // Clear the main screen
00328     system.fillScreen(0);
00329 }
00330 
00331 static void setupKeymapper(OSystem &system) {
00332 #ifdef ENABLE_KEYMAPPER
00333     using namespace Common;
00334 
00335     Keymapper *mapper = system.getEventManager()->getKeymapper();
00336 
00337     HardwareInputSet *inputSet = system.getHardwareInputSet();
00338 
00339     // Query backend for hardware keys and register them
00340     mapper->registerHardwareInputSet(inputSet);
00341 
00342     // Now create the global keymap
00343     Keymap *primaryGlobalKeymap = new Keymap(kGlobalKeymapName);
00344     Action *act;
00345     act = new Action(primaryGlobalKeymap, "MENU", _("Menu"));
00346     act->addEvent(EVENT_MAINMENU);
00347 
00348     act = new Action(primaryGlobalKeymap, "SKCT", _("Skip"));
00349     act->addKeyEvent(KeyState(KEYCODE_ESCAPE, ASCII_ESCAPE, 0));
00350 
00351     act = new Action(primaryGlobalKeymap, "PAUS", _("Pause"));
00352     act->addKeyEvent(KeyState(KEYCODE_SPACE, ' ', 0));
00353 
00354     act = new Action(primaryGlobalKeymap, "SKLI", _("Skip line"));
00355     act->addKeyEvent(KeyState(KEYCODE_PERIOD, '.', 0));
00356 
00357 #ifdef ENABLE_VKEYBD
00358     act = new Action(primaryGlobalKeymap, "VIRT", _("Display keyboard"));
00359     act->addEvent(EVENT_VIRTUAL_KEYBOARD);
00360 #endif
00361 
00362     act = new Action(primaryGlobalKeymap, "REMP", _("Remap keys"));
00363     act->addEvent(EVENT_KEYMAPPER_REMAP);
00364 
00365     act = new Action(primaryGlobalKeymap, "FULS", _("Toggle fullscreen"));
00366     act->addKeyEvent(KeyState(KEYCODE_RETURN, ASCII_RETURN, KBD_ALT));
00367 
00368     mapper->addGlobalKeymap(primaryGlobalKeymap);
00369     mapper->pushKeymap(kGlobalKeymapName, true);
00370 
00371     // Get the platform-specific global keymap (if it exists)
00372     Keymap *platformGlobalKeymap = system.getGlobalKeymap();
00373     if (platformGlobalKeymap) {
00374         String platformGlobalKeymapName = platformGlobalKeymap->getName();
00375         mapper->addGlobalKeymap(platformGlobalKeymap);
00376         mapper->pushKeymap(platformGlobalKeymapName, true);
00377     }
00378 #endif
00379 
00380 }
00381 
00382 extern "C" int scummvm_main(int argc, const char * const argv[]) {
00383     Common::String specialDebug;
00384     Common::String command;
00385 
00386     // Verify that the backend has been initialized (i.e. g_system has been set).
00387     assert(g_system);
00388     OSystem &system = *g_system;
00389 
00390     // Register config manager defaults
00391     Base::registerDefaults();
00392 
00393     // Parse the command line
00394     Common::StringMap settings;
00395     command = Base::parseCommandLine(settings, argc, argv);
00396 
00397     // Load the config file (possibly overridden via command line):
00398     if (settings.contains("config")) {
00399         ConfMan.loadConfigFile(settings["config"]);
00400         settings.erase("config");
00401     } else {
00402         ConfMan.loadDefaultConfigFile();
00403     }
00404 
00405     // Update the config file
00406     ConfMan.set("versioninfo", gScummVMVersion, Common::ConfigManager::kApplicationDomain);
00407 
00408     // Load and setup the debuglevel and the debug flags. We do this at the
00409     // soonest possible moment to ensure debug output starts early on, if
00410     // requested.
00411     if (settings.contains("debuglevel")) {
00412         gDebugLevel = (int)strtol(settings["debuglevel"].c_str(), 0, 10);
00413         printf("Debuglevel (from command line): %d\n", gDebugLevel);
00414         settings.erase("debuglevel"); // This option should not be passed to ConfMan.
00415     } else if (ConfMan.hasKey("debuglevel"))
00416         gDebugLevel = ConfMan.getInt("debuglevel");
00417 
00418     if (settings.contains("debugflags")) {
00419         specialDebug = settings["debugflags"];
00420         settings.erase("debugflags");
00421     } else if (ConfMan.hasKey("debugflags"))
00422         specialDebug = ConfMan.get("debugflags");
00423 
00424     if (settings.contains("debug-channels-only"))
00425         gDebugChannelsOnly = true;
00426 
00427 
00428     PluginManager::instance().init();
00429     PluginManager::instance().loadAllPlugins(); // load plugins for cached plugin manager
00430 
00431     // If we received an invalid music parameter via command line we check this here.
00432     // We can't check this before loading the music plugins.
00433     // On the other hand we cannot load the plugins before we know the file paths (in case of external plugins).
00434     if (settings.contains("music-driver")) {
00435         if (MidiDriver::getMusicType(MidiDriver::getDeviceHandle(settings["music-driver"])) == MT_INVALID) {
00436             warning("Unrecognized music driver '%s'. Switching to default device", settings["music-driver"].c_str());
00437             settings["music-driver"] = "auto";
00438         }
00439     }
00440 
00441     // Process the remaining command line settings. Must be done after the
00442     // config file and the plugins have been loaded.
00443     Common::Error res;
00444 
00445     // TODO: deal with settings that require plugins to be loaded
00446     if (Base::processSettings(command, settings, res)) {
00447         if (res.getCode() != Common::kNoError)
00448             warning("%s", res.getDesc().c_str());
00449         return res.getCode();
00450     }
00451 
00452     // Init the backend. Must take place after all config data (including
00453     // the command line params) was read.
00454     system.initBackend();
00455 
00456     // If we received an invalid graphics mode parameter via command line
00457     // we check this here. We can't do it until after the backend is inited,
00458     // or there won't be a graphics manager to ask for the supported modes.
00459 
00460     if (settings.contains("gfx-mode")) {
00461         const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
00462         Common::String option = settings["gfx-mode"];
00463         bool isValid = false;
00464 
00465         while (gm->name && !isValid) {
00466             isValid = !scumm_stricmp(gm->name, option.c_str());
00467             gm++;
00468         }
00469         if (!isValid) {
00470             warning("Unrecognized graphics mode '%s'. Switching to default mode", option.c_str());
00471             settings["gfx-mode"] = "default";
00472         }
00473     }
00474     if (settings.contains("disable-display")) {
00475         ConfMan.setInt("disable-display", 1, Common::ConfigManager::kTransientDomain);
00476     }
00477     setupGraphics(system);
00478 
00479     // Init the different managers that are used by the engines.
00480     // Do it here to prevent fragmentation later
00481     system.getAudioCDManager();
00482     MusicManager::instance();
00483     Common::DebugManager::instance();
00484 
00485     // Init the event manager. As the virtual keyboard is loaded here, it must
00486     // take place after the backend is initiated and the screen has been setup
00487     system.getEventManager()->init();
00488 
00489 #ifdef ENABLE_EVENTRECORDER
00490     // Directly after initializing the event manager, we will initialize our
00491     // event recorder.
00492     //
00493     // TODO: This is just to match the current behavior, when we further extend
00494     // our event recorder, we might do this at another place. Or even change
00495     // the whole API for that ;-).
00496     g_eventRec.RegisterEventSource();
00497 #endif
00498 
00499     Common::OSDMessageQueue::instance().registerEventSource();
00500 
00501     // Now as the event manager is created, setup the keymapper
00502     setupKeymapper(system);
00503 
00504 #ifdef USE_UPDATES
00505     if (!ConfMan.hasKey("updates_check") && g_system->getUpdateManager()) {
00506         GUI::UpdatesDialog dlg;
00507         dlg.runModal();
00508     }
00509 #endif
00510 
00511 #if defined(USE_CLOUD) && defined(USE_LIBCURL)
00512     CloudMan.init();
00513     CloudMan.syncSaves();
00514 #endif
00515 
00516     // Unless a game was specified, show the launcher dialog
00517     if (0 == ConfMan.getActiveDomain())
00518         launcherDialog();
00519 
00520     // FIXME: We're now looping the launcher. This, of course, doesn't
00521     // work as well as it should. In theory everything should be destroyed
00522     // cleanly, so this is now enabled to encourage people to fix bits :)
00523     while (0 != ConfMan.getActiveDomain()) {
00524         // Try to find a plugin which feels responsible for the specified game.
00525         const Plugin *plugin = detectPlugin();
00526         if (plugin) {
00527             // Unload all plugins not needed for this game,
00528             // to save memory
00529             PluginManager::instance().unloadPluginsExcept(PLUGIN_TYPE_ENGINE, plugin);
00530 
00531 #ifdef ENABLE_EVENTRECORDER
00532             Common::String recordMode = ConfMan.get("record_mode");
00533             Common::String recordFileName = ConfMan.get("record_file_name");
00534 
00535             if (recordMode == "record") {
00536                 g_eventRec.init(g_eventRec.generateRecordFileName(ConfMan.getActiveDomainName()), GUI::EventRecorder::kRecorderRecord);
00537             } else if (recordMode == "playback") {
00538                 g_eventRec.init(recordFileName, GUI::EventRecorder::kRecorderPlayback);
00539             } else if ((recordMode == "info") && (!recordFileName.empty())) {
00540                 Common::PlaybackFile record;
00541                 record.openRead(recordFileName);
00542                 debug("info:author=%s name=%s description=%s", record.getHeader().author.c_str(), record.getHeader().name.c_str(), record.getHeader().description.c_str());
00543                 break;
00544             }
00545 #endif
00546             // Try to run the game
00547             Common::Error result = runGame(plugin, system, specialDebug);
00548 
00549 #ifdef ENABLE_EVENTRECORDER
00550             // Flush Event recorder file. The recorder does not get reinitialized for next game
00551             // which is intentional. Only single game per session is allowed.
00552             g_eventRec.deinit();
00553 #endif
00554 
00555 #if defined(UNCACHED_PLUGINS) && defined(DYNAMIC_MODULES)
00556             // do our best to prevent fragmentation by unloading as soon as we can
00557             PluginManager::instance().unloadPluginsExcept(PLUGIN_TYPE_ENGINE, NULL, false);
00558             // reallocate the config manager to get rid of any fragmentation
00559             ConfMan.defragment();
00560 #endif
00561 
00562             // Did an error occur ?
00563             if (result.getCode() != Common::kNoError && result.getCode() != Common::kUserCanceled) {
00564                 // Shows an informative error dialog if starting the selected game failed.
00565                 GUI::displayErrorDialog(result, _("Error running game:"));
00566             }
00567 
00568             // Quit unless an error occurred, or Return to launcher was requested
00569 #ifndef FORCE_RTL
00570             if (result.getCode() == Common::kNoError && !g_system->getEventManager()->shouldRTL())
00571                 break;
00572 #endif
00573             // Reset RTL flag in case we want to load another engine
00574             g_system->getEventManager()->resetRTL();
00575 #ifdef FORCE_RTL
00576             g_system->getEventManager()->resetQuit();
00577 #endif
00578 #ifdef ENABLE_EVENTRECORDER
00579             if (g_eventRec.checkForContinueGame()) {
00580                 continue;
00581             }
00582 #endif
00583 
00584             // At this point, we usually return to the launcher. However, the
00585             // game may have requested that one or more other games be "chained"
00586             // to the current one, with optional save slots to start the games
00587             // at. At the time of writing, this is used for the Maniac Mansion
00588             // easter egg in Day of the Tentacle.
00589 
00590             Common::String chainedGame;
00591             int saveSlot = -1;
00592 
00593             ChainedGamesMan.pop(chainedGame, saveSlot);
00594 
00595             // Discard any command line options. It's unlikely that the user
00596             // wanted to apply them to *all* games ever launched.
00597             ConfMan.getDomain(Common::ConfigManager::kTransientDomain)->clear();
00598 
00599             if (!chainedGame.empty()) {
00600                 if (saveSlot != -1) {
00601                     ConfMan.setInt("save_slot", saveSlot, Common::ConfigManager::kTransientDomain);
00602                 }
00603                 // Start the chained game
00604                 ConfMan.setActiveDomain(chainedGame);
00605             } else {
00606                 // Clear the active config domain
00607                 ConfMan.setActiveDomain("");
00608             }
00609 
00610             PluginManager::instance().loadAllPlugins(); // only for cached manager
00611         } else {
00612             GUI::displayErrorDialog(_("Could not find any engine capable of running the selected game"));
00613 
00614             // Clear the active domain
00615             ConfMan.setActiveDomain("");
00616         }
00617 
00618         // reset the graphics to default
00619         setupGraphics(system);
00620         if (0 == ConfMan.getActiveDomain()) {
00621             launcherDialog();
00622         }
00623     }
00624 #ifdef USE_CLOUD
00625 #ifdef USE_SDL_NET
00626     Networking::LocalWebserver::destroy();
00627 #endif
00628 #ifdef USE_LIBCURL
00629     Networking::ConnectionManager::destroy();
00630     //I think it's important to destroy it after ConnectionManager
00631     Cloud::CloudManager::destroy();
00632 #endif
00633 #endif
00634     PluginManager::instance().unloadAllPlugins();
00635     PluginManager::destroy();
00636     GUI::GuiManager::destroy();
00637     Common::ConfigManager::destroy();
00638     Common::DebugManager::destroy();
00639     Common::OSDMessageQueue::destroy();
00640 #ifdef ENABLE_EVENTRECORDER
00641     GUI::EventRecorder::destroy();
00642 #endif
00643     Common::SearchManager::destroy();
00644 #ifdef USE_TRANSLATION
00645     Common::TranslationManager::destroy();
00646 #endif
00647     MusicManager::destroy();
00648     Graphics::CursorManager::destroy();
00649     Graphics::FontManager::destroy();
00650 #ifdef USE_FREETYPE2
00651     Graphics::shutdownTTF();
00652 #endif
00653     EngineManager::destroy();
00654     Graphics::YUVToRGBManager::destroy();
00655 
00656     return 0;
00657 }


Generated on Sat Mar 16 2019 05:01:44 for ResidualVM by doxygen 1.7.1
curved edge   curved edge