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     // 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::Error err = Common::kNoError;
00159     Engine *engine = 0;
00160 
00161 // Disabled in ResidualVM:
00162 #if 0//defined(SDL_BACKEND) && defined(USE_OPENGL) && defined(USE_RGB_COLOR)
00163     // HACK: We set up the requested graphics mode setting here to allow the
00164     // backend to switch from Surface SDL to OpenGL if necessary. This is
00165     // needed because otherwise the g_system->getSupportedFormats might return
00166     // bad values.
00167     g_system->beginGFXTransaction();
00168         g_system->setGraphicsMode(ConfMan.get("gfx_mode").c_str());
00169     if (g_system->endGFXTransaction() != OSystem::kTransactionSuccess) {
00170         warning("Switching graphics mode to '%s' failed", ConfMan.get("gfx_mode").c_str());
00171         return Common::kUnknownError;
00172     }
00173 #endif
00174 
00175     // Verify that the game path refers to an actual directory
00176     if (!dir.exists()) {
00177         err = Common::kPathDoesNotExist;
00178     } else if (!dir.isDirectory()) {
00179         err = Common::kPathNotDirectory;
00180     }
00181 
00182     // Create the game engine
00183     if (err.getCode() == Common::kNoError) {
00184         const MetaEngine &metaEngine = plugin->get<MetaEngine>();
00185         // Set default values for all of the custom engine options
00186         // Apparently some engines query them in their constructor, thus we
00187         // need to set this up before instance creation.
00188         const ExtraGuiOptions engineOptions = metaEngine.getExtraGuiOptions(Common::String());
00189         for (uint i = 0; i < engineOptions.size(); i++) {
00190             ConfMan.registerDefault(engineOptions[i].configOption, engineOptions[i].defaultState);
00191         }
00192 
00193         err = metaEngine.createInstance(&system, &engine);
00194     }
00195 
00196     // Check for errors
00197     if (!engine || err.getCode() != Common::kNoError) {
00198 
00199         // Print a warning; note that scummvm_main will also
00200         // display an error dialog, so we don't have to do this here.
00201         warning("%s failed to instantiate engine: %s (target '%s', path '%s')",
00202             plugin->getName(),
00203             err.getDesc().c_str(),
00204             ConfMan.getActiveDomainName().c_str(),
00205             dir.getPath().c_str()
00206             );
00207 
00208         // If a temporary target failed to launch, remove it from the configuration manager
00209         // so it not visible in the launcher.
00210         // Temporary targets are created when starting games from the command line using the game id.
00211         if (ConfMan.hasKey("id_came_from_command_line")) {
00212             ConfMan.removeGameDomain(ConfMan.getActiveDomainName().c_str());
00213         }
00214 
00215         return err;
00216     }
00217 
00218     // Set the window caption to the game name
00219     Common::String caption(ConfMan.get("description"));
00220 
00221     if (caption.empty()) {
00222         QualifiedGameDescriptor game = EngineMan.findTarget(ConfMan.getActiveDomainName());
00223         if (game.description) {
00224             caption = game.description;
00225         }
00226     }
00227     if (caption.empty())
00228         caption = ConfMan.getActiveDomainName(); // Use the domain (=target) name
00229     if (!caption.empty())   {
00230         system.setWindowCaption(caption.c_str());
00231     }
00232 
00233     //
00234     // Setup various paths in the SearchManager
00235     //
00236 
00237     // Add the game path to the directory search list
00238     engine->initializePath(dir);
00239 
00240     // Add extrapath (if any) to the directory search list
00241     if (ConfMan.hasKey("extrapath")) {
00242         dir = Common::FSNode(ConfMan.get("extrapath"));
00243         SearchMan.addDirectory(dir.getPath(), dir);
00244     }
00245 
00246     // If a second extrapath is specified on the app domain level, add that as well.
00247     // However, since the default hasKey() and get() check the app domain level,
00248     // verify that it's not already there before adding it. The search manager will
00249     // check for that too, so this check is mostly to avoid a warning message.
00250     if (ConfMan.hasKey("extrapath", Common::ConfigManager::kApplicationDomain)) {
00251         Common::String extraPath = ConfMan.get("extrapath", Common::ConfigManager::kApplicationDomain);
00252         if (!SearchMan.hasArchive(extraPath)) {
00253             dir = Common::FSNode(extraPath);
00254             SearchMan.addDirectory(dir.getPath(), dir);
00255         }
00256     }
00257 
00258     // On creation the engine should have set up all debug levels so we can use
00259     // the command line arguments here
00260     Common::StringTokenizer tokenizer(edebuglevels, " ,");
00261     while (!tokenizer.empty()) {
00262         Common::String token = tokenizer.nextToken();
00263         if (token.equalsIgnoreCase("all"))
00264             DebugMan.enableAllDebugChannels();
00265         else if (!DebugMan.enableDebugChannel(token))
00266             warning(_("Engine does not support debug level '%s'"), token.c_str());
00267     }
00268 
00269 #ifdef USE_TRANSLATION
00270     Common::String previousLanguage = TransMan.getCurrentLanguage();
00271     if (ConfMan.hasKey("gui_use_game_language")
00272         && ConfMan.getBool("gui_use_game_language")
00273         && ConfMan.hasKey("language")) {
00274         TransMan.setLanguage(ConfMan.get("language"));
00275     }
00276 #endif
00277 
00278     // Initialize any game-specific keymaps
00279     engine->initKeymap();
00280 
00281     // Inform backend that the engine is about to be run
00282     system.engineInit();
00283 
00284     // Run the engine
00285     Common::Error result = engine->run();
00286 
00287     // Inform backend that the engine finished
00288     system.engineDone();
00289 
00290     // Clean up any game-specific keymaps
00291     engine->deinitKeymap();
00292 
00293     // Free up memory
00294     delete engine;
00295 
00296     // We clear all debug levels again even though the engine should do it
00297     DebugMan.clearAllDebugChannels();
00298 
00299     // Reset the file/directory mappings
00300     SearchMan.clear();
00301 
00302 #ifdef USE_TRANSLATION
00303     TransMan.setLanguage(previousLanguage);
00304 #endif
00305 
00306     // Return result (== 0 means no error)
00307     return result;
00308 }
00309 
00310 static void setupGraphics(OSystem &system) {
00311 
00312     system.beginGFXTransaction();
00313         // Set the user specified graphics mode (if any).
00314         system.setGraphicsMode(ConfMan.get("gfx_mode").c_str());
00315 
00316         system.initSize(320, 200);
00317         system.launcherInitSize(640, 480); //ResidualVM specific
00318 
00319         if (ConfMan.hasKey("aspect_ratio"))
00320             system.setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio"));
00321         if (ConfMan.hasKey("fullscreen"))
00322             system.setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
00323         if (ConfMan.hasKey("filtering"))
00324             system.setFeatureState(OSystem::kFeatureFilteringMode, ConfMan.getBool("filtering"));
00325         if (ConfMan.hasKey("stretch_mode"))
00326             system.setStretchMode(ConfMan.get("stretch_mode").c_str());
00327     system.endGFXTransaction();
00328 
00329     // When starting up launcher for the first time, the user might have specified
00330     // a --gui-theme option, to allow that option to be working, we need to initialize
00331     // GUI here.
00332     // FIXME: Find a nicer way to allow --gui-theme to be working
00333     GUI::GuiManager::instance();
00334 
00335     // Set initial window caption
00336     system.setWindowCaption(gScummVMFullVersion);
00337 
00338     // Clear the main screen
00339     system.fillScreen(0);
00340 }
00341 
00342 static void setupKeymapper(OSystem &system) {
00343 #ifdef ENABLE_KEYMAPPER
00344     using namespace Common;
00345 
00346     Keymapper *mapper = system.getEventManager()->getKeymapper();
00347 
00348     HardwareInputSet *inputSet = system.getHardwareInputSet();
00349 
00350     // Query backend for hardware keys and register them
00351     mapper->registerHardwareInputSet(inputSet);
00352 
00353     // Now create the global keymap
00354     Keymap *primaryGlobalKeymap = new Keymap(kGlobalKeymapName);
00355     Action *act;
00356     act = new Action(primaryGlobalKeymap, "MENU", _("Menu"));
00357     act->addEvent(EVENT_MAINMENU);
00358 
00359     act = new Action(primaryGlobalKeymap, "SKCT", _("Skip"));
00360     act->addKeyEvent(KeyState(KEYCODE_ESCAPE, ASCII_ESCAPE, 0));
00361 
00362     act = new Action(primaryGlobalKeymap, "PAUS", _("Pause"));
00363     act->addKeyEvent(KeyState(KEYCODE_SPACE, ' ', 0));
00364 
00365     act = new Action(primaryGlobalKeymap, "SKLI", _("Skip line"));
00366     act->addKeyEvent(KeyState(KEYCODE_PERIOD, '.', 0));
00367 
00368 #ifdef ENABLE_VKEYBD
00369     act = new Action(primaryGlobalKeymap, "VIRT", _("Display keyboard"));
00370     act->addEvent(EVENT_VIRTUAL_KEYBOARD);
00371 #endif
00372 
00373     act = new Action(primaryGlobalKeymap, "REMP", _("Remap keys"));
00374     act->addEvent(EVENT_KEYMAPPER_REMAP);
00375 
00376     act = new Action(primaryGlobalKeymap, "FULS", _("Toggle fullscreen"));
00377     act->addKeyEvent(KeyState(KEYCODE_RETURN, ASCII_RETURN, KBD_ALT));
00378 
00379     mapper->addGlobalKeymap(primaryGlobalKeymap);
00380     mapper->pushKeymap(kGlobalKeymapName, true);
00381 
00382     // Get the platform-specific global keymap (if it exists)
00383     Keymap *platformGlobalKeymap = system.getGlobalKeymap();
00384     if (platformGlobalKeymap) {
00385         String platformGlobalKeymapName = platformGlobalKeymap->getName();
00386         mapper->addGlobalKeymap(platformGlobalKeymap);
00387         mapper->pushKeymap(platformGlobalKeymapName, true);
00388     }
00389 #endif
00390 
00391 }
00392 
00393 extern "C" int scummvm_main(int argc, const char * const argv[]) {
00394     Common::String specialDebug;
00395     Common::String command;
00396 
00397     // Verify that the backend has been initialized (i.e. g_system has been set).
00398     assert(g_system);
00399     OSystem &system = *g_system;
00400 
00401     // Register config manager defaults
00402     Base::registerDefaults();
00403 
00404     // Parse the command line
00405     Common::StringMap settings;
00406     command = Base::parseCommandLine(settings, argc, argv);
00407 
00408     // Load the config file (possibly overridden via command line):
00409     if (settings.contains("config")) {
00410         ConfMan.loadConfigFile(settings["config"]);
00411         settings.erase("config");
00412     } else {
00413         ConfMan.loadDefaultConfigFile();
00414     }
00415 
00416     // Update the config file
00417     ConfMan.set("versioninfo", gScummVMVersion, Common::ConfigManager::kApplicationDomain);
00418 
00419     // Load and setup the debuglevel and the debug flags. We do this at the
00420     // soonest possible moment to ensure debug output starts early on, if
00421     // requested.
00422     if (settings.contains("debuglevel")) {
00423         gDebugLevel = (int)strtol(settings["debuglevel"].c_str(), 0, 10);
00424         printf("Debuglevel (from command line): %d\n", gDebugLevel);
00425         settings.erase("debuglevel"); // This option should not be passed to ConfMan.
00426     } else if (ConfMan.hasKey("debuglevel"))
00427         gDebugLevel = ConfMan.getInt("debuglevel");
00428 
00429     if (settings.contains("debugflags")) {
00430         specialDebug = settings["debugflags"];
00431         settings.erase("debugflags");
00432     } else if (ConfMan.hasKey("debugflags"))
00433         specialDebug = ConfMan.get("debugflags");
00434 
00435     if (settings.contains("debug-channels-only"))
00436         gDebugChannelsOnly = true;
00437 
00438 
00439     PluginManager::instance().init();
00440     PluginManager::instance().loadAllPlugins(); // load plugins for cached plugin manager
00441 
00442     // If we received an invalid music parameter via command line we check this here.
00443     // We can't check this before loading the music plugins.
00444     // On the other hand we cannot load the plugins before we know the file paths (in case of external plugins).
00445     if (settings.contains("music-driver")) {
00446         if (MidiDriver::getMusicType(MidiDriver::getDeviceHandle(settings["music-driver"])) == MT_INVALID) {
00447             warning("Unrecognized music driver '%s'. Switching to default device", settings["music-driver"].c_str());
00448             settings["music-driver"] = "auto";
00449         }
00450     }
00451 
00452     // Process the remaining command line settings. Must be done after the
00453     // config file and the plugins have been loaded.
00454     Common::Error res;
00455 
00456     // TODO: deal with settings that require plugins to be loaded
00457     if (Base::processSettings(command, settings, res)) {
00458         if (res.getCode() != Common::kNoError)
00459             warning("%s", res.getDesc().c_str());
00460         return res.getCode();
00461     }
00462 
00463     // Init the backend. Must take place after all config data (including
00464     // the command line params) was read.
00465     system.initBackend();
00466 
00467     // If we received an invalid graphics mode parameter via command line
00468     // we check this here. We can't do it until after the backend is inited,
00469     // or there won't be a graphics manager to ask for the supported modes.
00470 
00471     if (settings.contains("gfx-mode")) {
00472         const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
00473         Common::String option = settings["gfx-mode"];
00474         bool isValid = false;
00475 
00476         while (gm->name && !isValid) {
00477             isValid = !scumm_stricmp(gm->name, option.c_str());
00478             gm++;
00479         }
00480         if (!isValid) {
00481             warning("Unrecognized graphics mode '%s'. Switching to default mode", option.c_str());
00482             settings["gfx-mode"] = "default";
00483         }
00484     }
00485     if (settings.contains("disable-display")) {
00486         ConfMan.setInt("disable-display", 1, Common::ConfigManager::kTransientDomain);
00487     }
00488     setupGraphics(system);
00489 
00490     // Init the different managers that are used by the engines.
00491     // Do it here to prevent fragmentation later
00492     system.getAudioCDManager();
00493     MusicManager::instance();
00494     Common::DebugManager::instance();
00495 
00496     // Init the event manager. As the virtual keyboard is loaded here, it must
00497     // take place after the backend is initiated and the screen has been setup
00498     system.getEventManager()->init();
00499 
00500 #ifdef ENABLE_EVENTRECORDER
00501     // Directly after initializing the event manager, we will initialize our
00502     // event recorder.
00503     //
00504     // TODO: This is just to match the current behavior, when we further extend
00505     // our event recorder, we might do this at another place. Or even change
00506     // the whole API for that ;-).
00507     g_eventRec.RegisterEventSource();
00508 #endif
00509 
00510     Common::OSDMessageQueue::instance().registerEventSource();
00511 
00512     // Now as the event manager is created, setup the keymapper
00513     setupKeymapper(system);
00514 
00515 #ifdef USE_UPDATES
00516     if (!ConfMan.hasKey("updates_check") && g_system->getUpdateManager()) {
00517         GUI::UpdatesDialog dlg;
00518         dlg.runModal();
00519     }
00520 #endif
00521 
00522 #if defined(USE_CLOUD) && defined(USE_LIBCURL)
00523     CloudMan.init();
00524     CloudMan.syncSaves();
00525 #endif
00526 
00527     // Unless a game was specified, show the launcher dialog
00528     if (0 == ConfMan.getActiveDomain())
00529         launcherDialog();
00530 
00531     // FIXME: We're now looping the launcher. This, of course, doesn't
00532     // work as well as it should. In theory everything should be destroyed
00533     // cleanly, so this is now enabled to encourage people to fix bits :)
00534     while (0 != ConfMan.getActiveDomain()) {
00535         saveLastLaunchedTarget(ConfMan.getActiveDomainName());
00536 
00537         EngineMan.upgradeTargetIfNecessary(ConfMan.getActiveDomainName());
00538 
00539         // Try to find a plugin which feels responsible for the specified game.
00540         const Plugin *plugin = detectPlugin();
00541         if (plugin) {
00542             // Unload all plugins not needed for this game,
00543             // to save memory
00544             PluginManager::instance().unloadPluginsExcept(PLUGIN_TYPE_ENGINE, plugin);
00545 
00546 #ifdef ENABLE_EVENTRECORDER
00547             Common::String recordMode = ConfMan.get("record_mode");
00548             Common::String recordFileName = ConfMan.get("record_file_name");
00549 
00550             if (recordMode == "record") {
00551                 g_eventRec.init(g_eventRec.generateRecordFileName(ConfMan.getActiveDomainName()), GUI::EventRecorder::kRecorderRecord);
00552             } else if (recordMode == "playback") {
00553                 g_eventRec.init(recordFileName, GUI::EventRecorder::kRecorderPlayback);
00554             } else if ((recordMode == "info") && (!recordFileName.empty())) {
00555                 Common::PlaybackFile record;
00556                 record.openRead(recordFileName);
00557                 debug("info:author=%s name=%s description=%s", record.getHeader().author.c_str(), record.getHeader().name.c_str(), record.getHeader().description.c_str());
00558                 break;
00559             }
00560 #endif
00561             // Try to run the game
00562             Common::Error result = runGame(plugin, system, specialDebug);
00563 
00564 #ifdef ENABLE_EVENTRECORDER
00565             // Flush Event recorder file. The recorder does not get reinitialized for next game
00566             // which is intentional. Only single game per session is allowed.
00567             g_eventRec.deinit();
00568 #endif
00569 
00570 #if defined(UNCACHED_PLUGINS) && defined(DYNAMIC_MODULES)
00571             // do our best to prevent fragmentation by unloading as soon as we can
00572             PluginManager::instance().unloadPluginsExcept(PLUGIN_TYPE_ENGINE, NULL, false);
00573             // reallocate the config manager to get rid of any fragmentation
00574             ConfMan.defragment();
00575 #endif
00576 
00577             // Did an error occur ?
00578             if (result.getCode() != Common::kNoError && result.getCode() != Common::kUserCanceled) {
00579                 // Shows an informative error dialog if starting the selected game failed.
00580                 GUI::displayErrorDialog(result, _("Error running game:"));
00581             }
00582 
00583             // Quit unless an error occurred, or Return to launcher was requested
00584 #ifndef FORCE_RTL
00585             if (result.getCode() == Common::kNoError && !g_system->getEventManager()->shouldRTL())
00586                 break;
00587 #endif
00588             // Reset RTL flag in case we want to load another engine
00589             g_system->getEventManager()->resetRTL();
00590 #ifdef FORCE_RTL
00591             g_system->getEventManager()->resetQuit();
00592 #endif
00593 #ifdef ENABLE_EVENTRECORDER
00594             if (g_eventRec.checkForContinueGame()) {
00595                 continue;
00596             }
00597 #endif
00598 
00599             // At this point, we usually return to the launcher. However, the
00600             // game may have requested that one or more other games be "chained"
00601             // to the current one, with optional save slots to start the games
00602             // at. At the time of writing, this is used for the Maniac Mansion
00603             // easter egg in Day of the Tentacle.
00604 
00605             Common::String chainedGame;
00606             int saveSlot = -1;
00607 
00608             ChainedGamesMan.pop(chainedGame, saveSlot);
00609 
00610             // Discard any command line options. It's unlikely that the user
00611             // wanted to apply them to *all* games ever launched.
00612             ConfMan.getDomain(Common::ConfigManager::kTransientDomain)->clear();
00613 
00614             if (!chainedGame.empty()) {
00615                 if (saveSlot != -1) {
00616                     ConfMan.setInt("save_slot", saveSlot, Common::ConfigManager::kTransientDomain);
00617                 }
00618                 // Start the chained game
00619                 ConfMan.setActiveDomain(chainedGame);
00620             } else {
00621                 // Clear the active config domain
00622                 ConfMan.setActiveDomain("");
00623             }
00624 
00625             PluginManager::instance().loadAllPluginsOfType(PLUGIN_TYPE_ENGINE); // only for cached manager
00626         } else {
00627             GUI::displayErrorDialog(_("Could not find any engine capable of running the selected game"));
00628 
00629             // Clear the active domain
00630             ConfMan.setActiveDomain("");
00631         }
00632 
00633         // reset the graphics to default
00634         setupGraphics(system);
00635         if (0 == ConfMan.getActiveDomain()) {
00636             launcherDialog();
00637         }
00638     }
00639 #ifdef USE_CLOUD
00640 #ifdef USE_SDL_NET
00641     Networking::LocalWebserver::destroy();
00642 #endif
00643 #ifdef USE_LIBCURL
00644     Networking::ConnectionManager::destroy();
00645     //I think it's important to destroy it after ConnectionManager
00646     Cloud::CloudManager::destroy();
00647 #endif
00648 #endif
00649     PluginManager::instance().unloadAllPlugins();
00650     PluginManager::destroy();
00651     GUI::GuiManager::destroy();
00652     Common::ConfigManager::destroy();
00653     Common::DebugManager::destroy();
00654     Common::OSDMessageQueue::destroy();
00655 #ifdef ENABLE_EVENTRECORDER
00656     GUI::EventRecorder::destroy();
00657 #endif
00658     Common::SearchManager::destroy();
00659 #ifdef USE_TRANSLATION
00660     Common::TranslationManager::destroy();
00661 #endif
00662     MusicManager::destroy();
00663     Graphics::CursorManager::destroy();
00664     Graphics::FontManager::destroy();
00665 #ifdef USE_FREETYPE2
00666     Graphics::shutdownTTF();
00667 #endif
00668     EngineManager::destroy();
00669     Graphics::YUVToRGBManager::destroy();
00670 
00671     return 0;
00672 }


Generated on Sat Apr 4 2020 05:00:26 for ResidualVM by doxygen 1.7.1
curved edge   curved edge