From 3628629007e4b97b7b634d0545e3acd474c7708b Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 15 Apr 2006 13:12:03 +0000 Subject: - Replaced ConfigManager::_globalDomains by _appDomain (we don't support multiple global domains anymore) - Restructured parts of the ConfigManager to be more consistent and a bit easier to understand - Introduced ConfigManager::getDomain, potentially useful for code that needs to edit a specific domain (like the option dialogs) - Allow passing an empty string to ConfigManager::setActiveDomain(), to reset the active domain - Discard all transient config options (i.e. mostly command line settings) when entering the launcher, and after an engine exits - Introduced various hidden easter bugs. Happy easter, and have fun searching! svn-id: r21906 --- base/engine.cpp | 25 +++++++++++++++++++------ base/gameDetector.cpp | 4 ++++ base/main.cpp | 19 +++++++++++++------ 3 files changed, 36 insertions(+), 12 deletions(-) (limited to 'base') diff --git a/base/engine.cpp b/base/engine.cpp index fb46949050..a3767d1bf4 100644 --- a/base/engine.cpp +++ b/base/engine.cpp @@ -56,12 +56,18 @@ Engine::~Engine() { } void Engine::initCommonGFX(GameDetector &detector, bool defaultTo1XScaler) { + const Common::ConfigManager::Domain *transientDomain = ConfMan.getDomain(Common::ConfigManager::kTransientDomain); + const Common::ConfigManager::Domain *gameDomain = ConfMan.getDomain(detector._targetName); + + assert(transientDomain); + const bool useDefaultGraphicsMode = - !ConfMan.hasKey("gfx_mode", Common::ConfigManager::kTransientDomain) && + !transientDomain->contains("gfx_mode") && ( - !ConfMan.hasKey("gfx_mode", detector._targetName) || - !scumm_stricmp(ConfMan.get("gfx_mode", detector._targetName).c_str(), "normal") || - !scumm_stricmp(ConfMan.get("gfx_mode", detector._targetName).c_str(), "default") + !gameDomain || + !gameDomain->contains("gfx_mode") || + !scumm_stricmp(gameDomain->get("gfx_mode").c_str(), "normal") || + !scumm_stricmp(gameDomain->get("gfx_mode").c_str(), "default") ); // See if the game should default to 1x scaler @@ -77,12 +83,19 @@ void Engine::initCommonGFX(GameDetector &detector, bool defaultTo1XScaler) { } } + // Note: The following code deals with the fullscreen / ASR settings. This + // is a bit tricky, because there are three ways the user can affect these + // settings: Via the config file, via the command line, and via in-game + // hotkeys. + // Any global or command line settings already have been applied at the time + // we get here. Hence we only do something + // (De)activate aspect-ratio correction as determined by the config settings - if (ConfMan.hasKey("aspect_ratio", detector._targetName)) + if (gameDomain && gameDomain->contains("aspect_ratio")) _system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio")); // (De)activate fullscreen mode as determined by the config settings - if (ConfMan.hasKey("fullscreen", detector._targetName)) + if (gameDomain && gameDomain->contains("fullscreen")) _system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen")); } diff --git a/base/gameDetector.cpp b/base/gameDetector.cpp index b21ccffb6b..fe762b4994 100644 --- a/base/gameDetector.cpp +++ b/base/gameDetector.cpp @@ -602,6 +602,10 @@ void GameDetector::setTarget(const String &target) { _gameid = ConfMan.get("gameid"); else _gameid = _targetName; + + // TODO: In the future, simply insert the gameid into the transient domain. + // That way, all code (including backends) can reliably access it. + //ConfMan.set("gameid", _gameid, Common::ConfigManager::kTransientDomain); } bool GameDetector::detectMain() { diff --git a/base/main.cpp b/base/main.cpp index fabcce5b89..afa163625c 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -314,8 +314,15 @@ extern "C" int scummvm_main(int argc, char *argv[]) { setupDummyPalette(system); // Unless a game was specified, show the launcher dialog - if (detector._targetName.empty()) + if (detector._targetName.empty()) { + // Discard any command line options. Those that affect the graphics + // mode etc. already have should have been handled by the backend at + // this point. And the others (like bootparam etc.) should not + // blindly be passed to the first game launched from the launcher. + ConfMan.getDomain(Common::ConfigManager::kTransientDomain)->clear(); + running = launcherDialog(detector, system); + } // FIXME: We're now looping the launcher. This, of course, doesn't // work as well as it should. In theory everything should be destroyed @@ -331,11 +338,11 @@ extern "C" int scummvm_main(int argc, char *argv[]) { if (result == 0) break; - // There are some command-line options that it's - // unlikely that we want to preserve now that we're - // going to start a different game. - ConfMan.removeKey("boot_param", ConfMan.kTransientDomain); - ConfMan.removeKey("save_slot", ConfMan.kTransientDomain); + // Discard any command line options. It's unlikely that the user + // wanted to apply them to *all* games ever launched. + ConfMan.getDomain(Common::ConfigManager::kTransientDomain)->clear(); + + // TODO: Reset the game detector fully // PluginManager::instance().unloadPlugins(); PluginManager::instance().loadPlugins(); -- cgit v1.2.3