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/text-to-speech.h"
00055 #include "common/osd_message_queue.h"
00056 
00057 #include "gui/gui-manager.h"
00058 #include "gui/error.h"
00059 
00060 #include "audio/mididrv.h"
00061 #include "audio/musicplugin.h"  /* for music manager */
00062 
00063 #include "graphics/cursorman.h"
00064 #include "graphics/fontman.h"
00065 #include "graphics/yuv_to_rgb.h"
00066 #ifdef USE_FREETYPE2
00067 #include "graphics/fonts/ttf.h"
00068 #endif
00069 
00070 #include "backends/keymapper/action.h"
00071 #include "backends/keymapper/keymap.h"
00072 #include "backends/keymapper/keymapper.h"
00073 
00074 #ifdef USE_CLOUD
00075 #ifdef USE_LIBCURL
00076 #include "backends/cloud/cloudmanager.h"
00077 #include "backends/networking/curl/connectionmanager.h"
00078 #endif
00079 #ifdef USE_SDL_NET
00080 #include "backends/networking/sdl_net/localwebserver.h"
00081 #endif
00082 #endif
00083 
00084 #if defined(__DC__)
00085 #include "backends/platform/dc/DCLauncherDialog.h"
00086 #else
00087 #include "gui/launcher.h"
00088 #endif
00089 
00090 #ifdef USE_UPDATES
00091 #include "gui/updates-dialog.h"
00092 #endif
00093 
00094 static bool launcherDialog() {
00095 
00096     // Discard any command line options. Those that affect the graphics
00097     // mode and the others (like bootparam etc.) should not
00098     // blindly be passed to the first game launched from the launcher.
00099     ConfMan.getDomain(Common::ConfigManager::kTransientDomain)->clear();
00100 
00101 #if 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     // Figure out the engine ID and game ID
00111     Common::String engineId = ConfMan.get("engineid");
00112     Common::String gameId = ConfMan.get("gameid");
00113 
00114     // Print text saying what's going on
00115     printf("User picked target '%s' (engine ID '%s', game ID '%s')...\n", ConfMan.getActiveDomainName().c_str(), engineId.c_str(), gameId.c_str());
00116 
00117     // At this point the engine ID and game ID must be known
00118     if (engineId.empty()) {
00119         warning("The engine ID is not set for target '%s'", ConfMan.getActiveDomainName().c_str());
00120         return 0;
00121     }
00122 
00123     if (gameId.empty()) {
00124         warning("The game ID is not set for target '%s'", ConfMan.getActiveDomainName().c_str());
00125         return 0;
00126     }
00127 
00128     const Plugin *plugin = EngineMan.findPlugin(engineId);
00129     if (!plugin) {
00130         warning("'%s' is an invalid engine ID. Use the --list-engines command to list supported engine IDs", engineId.c_str());
00131         return 0;
00132     }
00133 
00134     // Query the plugin for the game descriptor
00135     printf("   Looking for a plugin supporting this target... %s\n", plugin->getName());
00136     PlainGameDescriptor game = plugin->get<MetaEngine>().findGame(gameId.c_str());
00137     if (!game.gameId) {
00138         warning("'%s' is an invalid game ID for the engine '%s'. Use the --list-games option to list supported game IDs", gameId.c_str(), engineId.c_str());
00139         return 0;
00140     }
00141 
00142     return plugin;
00143 }
00144 
00145 void saveLastLaunchedTarget(const Common::String &target) {
00146     if (ConfMan.hasGameDomain(target)) {
00147         // Set the last selected game, so the game will be highlighted next time the user
00148         // returns to the launcher.
00149         ConfMan.set("lastselectedgame", target, Common::ConfigManager::kApplicationDomain);
00150         ConfMan.flushToDisk();
00151     }
00152 }
00153 
00154 // TODO: specify the possible return values here
00155 static Common::Error runGame(const Plugin *plugin, OSystem &system, const Common::String &edebuglevels) {
00156     // Determine the game data path, for validation and error messages
00157     Common::FSNode dir(ConfMan.get("path"));
00158     Common::String target = ConfMan.getActiveDomainName();
00159     Common::Error err = Common::kNoError;
00160     Engine *engine = 0;
00161 
00162 // Disabled in ResidualVM:
00163 #if 0//defined(SDL_BACKEND) && defined(USE_OPENGL) && defined(USE_RGB_COLOR)
00164     // HACK: We set up the requested graphics mode setting here to allow the
00165     // backend to switch from Surface SDL to OpenGL if necessary. This is
00166     // needed because otherwise the g_system->getSupportedFormats might return
00167     // bad values.
00168     g_system->beginGFXTransaction();
00169         g_system->setGraphicsMode(ConfMan.get("gfx_mode").c_str());
00170     if (g_system->endGFXTransaction() != OSystem::kTransactionSuccess) {
00171         warning("Switching graphics mode to '%s' failed", ConfMan.get("gfx_mode").c_str());
00172         return Common::kUnknownError;
00173     }
00174 #endif
00175 
00176     // Verify that the game path refers to an actual directory
00177     if (!dir.exists()) {
00178         err = Common::kPathDoesNotExist;
00179     } else if (!dir.isDirectory()) {
00180         err = Common::kPathNotDirectory;
00181     }
00182 
00183     // Create the game engine
00184     const MetaEngine &metaEngine = plugin->get<MetaEngine>();
00185     if (err.getCode() == Common::kNoError) {
00186         // Set default values for all of the custom engine options
00187         // Apparently some engines query them in their constructor, thus we
00188         // need to set this up before instance creation.
00189         metaEngine.registerDefaultSettings(target);
00190 
00191         err = metaEngine.createInstance(&system, &engine);
00192     }
00193 
00194     // Check for errors
00195     if (!engine || err.getCode() != Common::kNoError) {
00196 
00197         // Print a warning; note that scummvm_main will also
00198         // display an error dialog, so we don't have to do this here.
00199         warning("%s failed to instantiate engine: %s (target '%s', path '%s')",
00200             plugin->getName(),
00201             err.getDesc().c_str(),
00202             target.c_str(),
00203             dir.getPath().c_str()
00204             );
00205 
00206         // If a temporary target failed to launch, remove it from the configuration manager
00207         // so it not visible in the launcher.
00208         // Temporary targets are created when starting games from the command line using the game id.
00209         if (ConfMan.hasKey("id_came_from_command_line")) {
00210             ConfMan.removeGameDomain(target.c_str());
00211         }
00212 
00213         return err;
00214     }
00215 
00216     // Set the window caption to the game name
00217     Common::String caption(ConfMan.get("description"));
00218 
00219     if (caption.empty()) {
00220         PlainGameDescriptor game = metaEngine.findGame(ConfMan.get("gameid").c_str());
00221         if (game.description) {
00222             caption = game.description;
00223         }
00224     }
00225     if (caption.empty())
00226         caption = target;
00227     if (!caption.empty())   {
00228         system.setWindowCaption(caption.c_str());
00229     }
00230 
00231     //
00232     // Setup various paths in the SearchManager
00233     //
00234 
00235     // Add the game path to the directory search list
00236     engine->initializePath(dir);
00237 
00238     // Add extrapath (if any) to the directory search list
00239     if (ConfMan.hasKey("extrapath")) {
00240         dir = Common::FSNode(ConfMan.get("extrapath"));
00241         SearchMan.addDirectory(dir.getPath(), dir);
00242     }
00243 
00244     // If a second extrapath is specified on the app domain level, add that as well.
00245     // However, since the default hasKey() and get() check the app domain level,
00246     // verify that it's not already there before adding it. The search manager will
00247     // check for that too, so this check is mostly to avoid a warning message.
00248     if (ConfMan.hasKey("extrapath", Common::ConfigManager::kApplicationDomain)) {
00249         Common::String extraPath = ConfMan.get("extrapath", Common::ConfigManager::kApplicationDomain);
00250         if (!SearchMan.hasArchive(extraPath)) {
00251             dir = Common::FSNode(extraPath);
00252             SearchMan.addDirectory(dir.getPath(), dir);
00253         }
00254     }
00255 
00256     // On creation the engine should have set up all debug levels so we can use
00257     // the command line arguments here
00258     Common::StringTokenizer tokenizer(edebuglevels, " ,");
00259     while (!tokenizer.empty()) {
00260         Common::String token = tokenizer.nextToken();
00261         if (token.equalsIgnoreCase("all"))
00262             DebugMan.enableAllDebugChannels();
00263         else if (!DebugMan.enableDebugChannel(token))
00264             warning(_("Engine does not support debug level '%s'"), token.c_str());
00265     }
00266 
00267 #ifdef USE_TRANSLATION
00268     Common::String previousLanguage = TransMan.getCurrentLanguage();
00269     if (ConfMan.hasKey("gui_use_game_language")
00270         && ConfMan.getBool("gui_use_game_language")
00271         && ConfMan.hasKey("language")) {
00272         TransMan.setLanguage(ConfMan.get("language"));
00273 #ifdef USE_TTS
00274         Common::TextToSpeechManager *ttsMan;
00275         if ((ttsMan = g_system->getTextToSpeechManager()) != nullptr) {
00276             ttsMan->setLanguage(ConfMan.get("language"));
00277         }
00278 #endif // USE_TTS
00279     }
00280 #endif // USE_TRANSLATION
00281 
00282     // Initialize any game-specific keymaps
00283     Common::KeymapArray gameKeymaps = metaEngine.initKeymaps(target.c_str());
00284     Common::Keymapper *keymapper = system.getEventManager()->getKeymapper();
00285     for (uint i = 0; i < gameKeymaps.size(); i++) {
00286         keymapper->addGameKeymap(gameKeymaps[i]);
00287     }
00288 
00289     // Inform backend that the engine is about to be run
00290     system.engineInit();
00291 
00292     // Run the engine
00293     Common::Error result = engine->run();
00294 
00295     // Inform backend that the engine finished
00296     system.engineDone();
00297 
00298     // Clean up any game-specific keymaps
00299     keymapper->cleanupGameKeymaps();
00300 
00301     // Free up memory
00302     delete engine;
00303 
00304     // We clear all debug levels again even though the engine should do it
00305     DebugMan.clearAllDebugChannels();
00306 
00307     // Reset the file/directory mappings
00308     SearchMan.clear();
00309 
00310 #ifdef USE_TRANSLATION
00311     TransMan.setLanguage(previousLanguage);
00312 #ifdef USE_TTS
00313         Common::TextToSpeechManager *ttsMan;
00314         if ((ttsMan = g_system->getTextToSpeechManager()) != nullptr) {
00315             ttsMan->setLanguage(ConfMan.get("language"));
00316         }
00317 #endif // USE_TTS
00318 #endif // USE_TRANSLATION
00319 
00320     // Return result (== 0 means no error)
00321     return result;
00322 }
00323 
00324 static void setupGraphics(OSystem &system) {
00325 
00326     system.beginGFXTransaction();
00327         // Set the user specified graphics mode (if any).
00328         system.setGraphicsMode(ConfMan.get("gfx_mode").c_str());
00329 
00330         system.initSize(320, 200);
00331         system.launcherInitSize(640, 480); //ResidualVM specific
00332 
00333         if (ConfMan.hasKey("aspect_ratio"))
00334             system.setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio"));
00335         if (ConfMan.hasKey("fullscreen"))
00336             system.setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
00337         if (ConfMan.hasKey("filtering"))
00338             system.setFeatureState(OSystem::kFeatureFilteringMode, ConfMan.getBool("filtering"));
00339         if (ConfMan.hasKey("stretch_mode"))
00340             system.setStretchMode(ConfMan.get("stretch_mode").c_str());
00341         if (ConfMan.hasKey("shader"))
00342             system.setShader(ConfMan.get("shader").c_str());
00343     system.endGFXTransaction();
00344 
00345     // When starting up launcher for the first time, the user might have specified
00346     // a --gui-theme option, to allow that option to be working, we need to initialize
00347     // GUI here.
00348     // FIXME: Find a nicer way to allow --gui-theme to be working
00349     GUI::GuiManager::instance();
00350 
00351     // Set initial window caption
00352     system.setWindowCaption(gScummVMFullVersion);
00353 
00354     // Clear the main screen
00355     system.fillScreen(0);
00356 }
00357 
00358 static void setupKeymapper(OSystem &system) {
00359     using namespace Common;
00360 
00361     Keymapper *mapper = system.getEventManager()->getKeymapper();
00362     mapper->clear();
00363 
00364     // Query the backend for hardware keys and default bindings and register them
00365     HardwareInputSet *inputSet = system.getHardwareInputSet();
00366     KeymapperDefaultBindings *backendDefaultBindings = system.getKeymapperDefaultBindings();
00367 
00368     mapper->registerHardwareInputSet(inputSet, backendDefaultBindings);
00369 
00370     Keymap *primaryGlobalKeymap = system.getEventManager()->getGlobalKeymap();
00371     if (primaryGlobalKeymap) {
00372         mapper->addGlobalKeymap(primaryGlobalKeymap);
00373     }
00374 
00375     // Get the platform-specific global keymap (if it exists)
00376     KeymapArray platformKeymaps = system.getGlobalKeymaps();
00377     for (uint i = 0; i < platformKeymaps.size(); i++) {
00378         mapper->addGlobalKeymap(platformKeymaps[i]);
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     if (settings.contains("dump-midi")) {
00453         // Store this command line setting in ConfMan, since all transient settings are destroyed
00454         ConfMan.registerDefault("dump_midi", true);
00455     }
00456 
00457 
00458     // Init the backend. Must take place after all config data (including
00459     // the command line params) was read.
00460     system.initBackend();
00461 
00462     // If we received an invalid graphics mode parameter via command line
00463     // we check this here. We can't do it until after the backend is inited,
00464     // or there won't be a graphics manager to ask for the supported modes.
00465 
00466     if (settings.contains("gfx-mode")) {
00467         const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
00468         Common::String option = settings["gfx-mode"];
00469         bool isValid = false;
00470 
00471         while (gm->name && !isValid) {
00472             isValid = !scumm_stricmp(gm->name, option.c_str());
00473             gm++;
00474         }
00475         if (!isValid) {
00476             warning("Unrecognized graphics mode '%s'. Switching to default mode", option.c_str());
00477             settings["gfx-mode"] = "default";
00478         }
00479     }
00480     if (settings.contains("disable-display")) {
00481         ConfMan.setInt("disable-display", 1, Common::ConfigManager::kTransientDomain);
00482     }
00483     setupGraphics(system);
00484 
00485     // Init the different managers that are used by the engines.
00486     // Do it here to prevent fragmentation later
00487     system.getAudioCDManager();
00488     MusicManager::instance();
00489     Common::DebugManager::instance();
00490 
00491     // Init the event manager. As the virtual keyboard is loaded here, it must
00492     // take place after the backend is initiated and the screen has been setup
00493     system.getEventManager()->init();
00494 
00495 #ifdef ENABLE_EVENTRECORDER
00496     // Directly after initializing the event manager, we will initialize our
00497     // event recorder.
00498     //
00499     // TODO: This is just to match the current behavior, when we further extend
00500     // our event recorder, we might do this at another place. Or even change
00501     // the whole API for that ;-).
00502     g_eventRec.RegisterEventSource();
00503 #endif
00504 
00505     Common::OSDMessageQueue::instance().registerEventSource();
00506 
00507     // Now as the event manager is created, setup the keymapper
00508     setupKeymapper(system);
00509 
00510 #ifdef USE_UPDATES
00511     if (!ConfMan.hasKey("updates_check") && g_system->getUpdateManager()) {
00512         GUI::UpdatesDialog dlg;
00513         dlg.runModal();
00514     }
00515 #endif
00516 
00517 #if defined(USE_CLOUD) && defined(USE_LIBCURL)
00518     CloudMan.init();
00519     CloudMan.syncSaves();
00520 #endif
00521 
00522     // Unless a game was specified, show the launcher dialog
00523     if (0 == ConfMan.getActiveDomain())
00524         launcherDialog();
00525 
00526     // FIXME: We're now looping the launcher. This, of course, doesn't
00527     // work as well as it should. In theory everything should be destroyed
00528     // cleanly, so this is now enabled to encourage people to fix bits :)
00529     while (0 != ConfMan.getActiveDomain()) {
00530         saveLastLaunchedTarget(ConfMan.getActiveDomainName());
00531 
00532         EngineMan.upgradeTargetIfNecessary(ConfMan.getActiveDomainName());
00533 
00534         // Try to find a plugin which feels responsible for the specified game.
00535         const Plugin *plugin = detectPlugin();
00536         if (plugin) {
00537             // Unload all plugins not needed for this game,
00538             // to save memory
00539             PluginManager::instance().unloadPluginsExcept(PLUGIN_TYPE_ENGINE, plugin);
00540 
00541 #ifdef ENABLE_EVENTRECORDER
00542             Common::String recordMode = ConfMan.get("record_mode");
00543             Common::String recordFileName = ConfMan.get("record_file_name");
00544 
00545             if (recordMode == "record") {
00546                 g_eventRec.init(g_eventRec.generateRecordFileName(ConfMan.getActiveDomainName()), GUI::EventRecorder::kRecorderRecord);
00547             } else if (recordMode == "playback") {
00548                 g_eventRec.init(recordFileName, GUI::EventRecorder::kRecorderPlayback);
00549             } else if ((recordMode == "info") && (!recordFileName.empty())) {
00550                 Common::PlaybackFile record;
00551                 record.openRead(recordFileName);
00552                 debug("info:author=%s name=%s description=%s", record.getHeader().author.c_str(), record.getHeader().name.c_str(), record.getHeader().description.c_str());
00553                 break;
00554             }
00555 #endif
00556 #ifdef USE_TTS
00557             Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
00558             if (ttsMan != nullptr) {
00559                 ttsMan->pushState();
00560             }
00561 #endif
00562             // Try to run the game
00563             Common::Error result = runGame(plugin, system, specialDebug);
00564 
00565 #ifdef USE_TTS
00566             if (ttsMan != nullptr) {
00567                 ttsMan->popState();
00568             }
00569 #endif
00570 
00571 #ifdef ENABLE_EVENTRECORDER
00572             // Flush Event recorder file. The recorder does not get reinitialized for next game
00573             // which is intentional. Only single game per session is allowed.
00574             g_eventRec.deinit();
00575 #endif
00576 
00577 #if defined(UNCACHED_PLUGINS) && defined(DYNAMIC_MODULES)
00578             // do our best to prevent fragmentation by unloading as soon as we can
00579             PluginManager::instance().unloadPluginsExcept(PLUGIN_TYPE_ENGINE, NULL, false);
00580             // reallocate the config manager to get rid of any fragmentation
00581             ConfMan.defragment();
00582             // The keymapper keeps pointers to the configuration domains. It needs to be reinitialized.
00583             setupKeymapper(system);
00584 #endif
00585 
00586             // Did an error occur ?
00587             if (result.getCode() != Common::kNoError && result.getCode() != Common::kUserCanceled) {
00588                 // Shows an informative error dialog if starting the selected game failed.
00589                 GUI::displayErrorDialog(result, _("Error running game:"));
00590             }
00591 
00592             // Quit unless an error occurred, or Return to launcher was requested
00593 #ifndef FORCE_RETURN_TO_LAUNCHER
00594             if (result.getCode() == Common::kNoError && !g_system->getEventManager()->shouldReturnToLauncher())
00595                 break;
00596 #endif
00597             // Reset the return to launcher flag in case we want to load another engine
00598             g_system->getEventManager()->resetReturnToLauncher();
00599 #ifdef FORCE_RETURN_TO_LAUNCHER
00600             g_system->getEventManager()->resetQuit();
00601 #endif
00602 #ifdef ENABLE_EVENTRECORDER
00603             if (g_eventRec.checkForContinueGame()) {
00604                 continue;
00605             }
00606 #endif
00607 
00608             // At this point, we usually return to the launcher. However, the
00609             // game may have requested that one or more other games be "chained"
00610             // to the current one, with optional save slots to start the games
00611             // at. At the time of writing, this is used for the Maniac Mansion
00612             // easter egg in Day of the Tentacle.
00613 
00614             Common::String chainedGame;
00615             int saveSlot = -1;
00616 
00617             ChainedGamesMan.pop(chainedGame, saveSlot);
00618 
00619             // Discard any command line options. It's unlikely that the user
00620             // wanted to apply them to *all* games ever launched.
00621             ConfMan.getDomain(Common::ConfigManager::kTransientDomain)->clear();
00622 
00623             if (!chainedGame.empty()) {
00624                 if (saveSlot != -1) {
00625                     ConfMan.setInt("save_slot", saveSlot, Common::ConfigManager::kTransientDomain);
00626                 }
00627                 // Start the chained game
00628                 ConfMan.setActiveDomain(chainedGame);
00629             } else {
00630                 // Clear the active config domain
00631                 ConfMan.setActiveDomain("");
00632             }
00633 
00634             PluginManager::instance().loadAllPluginsOfType(PLUGIN_TYPE_ENGINE); // only for cached manager
00635         } else {
00636             GUI::displayErrorDialog(_("Could not find any engine capable of running the selected game"));
00637 
00638             // Clear the active domain
00639             ConfMan.setActiveDomain("");
00640         }
00641 
00642         // reset the graphics to default
00643         setupGraphics(system);
00644         if (0 == ConfMan.getActiveDomain()) {
00645             launcherDialog();
00646         }
00647     }
00648 #ifdef USE_CLOUD
00649 #ifdef USE_SDL_NET
00650     Networking::LocalWebserver::destroy();
00651 #endif
00652 #ifdef USE_LIBCURL
00653     Networking::ConnectionManager::destroy();
00654     //I think it's important to destroy it after ConnectionManager
00655     Cloud::CloudManager::destroy();
00656 #endif
00657 #endif
00658     PluginManager::instance().unloadAllPlugins();
00659     PluginManager::destroy();
00660     GUI::GuiManager::destroy();
00661     Common::ConfigManager::destroy();
00662     Common::DebugManager::destroy();
00663     Common::OSDMessageQueue::destroy();
00664 #ifdef ENABLE_EVENTRECORDER
00665     GUI::EventRecorder::destroy();
00666 #endif
00667     Common::SearchManager::destroy();
00668 #ifdef USE_TRANSLATION
00669     Common::TranslationManager::destroy();
00670 #endif
00671     MusicManager::destroy();
00672     Graphics::CursorManager::destroy();
00673     Graphics::FontManager::destroy();
00674 #ifdef USE_FREETYPE2
00675     Graphics::shutdownTTF();
00676 #endif
00677     EngineManager::destroy();
00678     Graphics::YUVToRGBManager::destroy();
00679 
00680     return 0;
00681 }


Generated on Sat Aug 8 2020 05:01:06 for ResidualVM by doxygen 1.7.1
curved edge   curved edge