diff options
author | Max Horn | 2006-04-15 20:36:41 +0000 |
---|---|---|
committer | Max Horn | 2006-04-15 20:36:41 +0000 |
commit | 68cb7f52c8dd64ccfe8f28e847b530c8835175c3 (patch) | |
tree | 635011611fbc8592289b85c0b704d5a0cec057ea /base | |
parent | ad45318328e23b76e346414c62ef4c22d8ebe059 (diff) | |
download | scummvm-rg350-68cb7f52c8dd64ccfe8f28e847b530c8835175c3.tar.gz scummvm-rg350-68cb7f52c8dd64ccfe8f28e847b530c8835175c3.tar.bz2 scummvm-rg350-68cb7f52c8dd64ccfe8f28e847b530c8835175c3.zip |
- Renamed ConfigManager::getActiveDomain to getActiveDomainName, and added a new getActiveDomain method that returns a pointer to the actual active *domain*
- Added Engine::_targetName whose value is computed from the name of the active domain
- Removed GameDetector::_targetName, instead code now uses either Engine::_targetName or the name of the active domain
- This in turn allowed for removing usage of GameDetector in many places
svn-id: r21916
Diffstat (limited to 'base')
-rw-r--r-- | base/engine.cpp | 9 | ||||
-rw-r--r-- | base/engine.h | 6 | ||||
-rw-r--r-- | base/gameDetector.cpp | 7 | ||||
-rw-r--r-- | base/gameDetector.h | 3 | ||||
-rw-r--r-- | base/main.cpp | 16 | ||||
-rw-r--r-- | base/plugins.cpp | 11 | ||||
-rw-r--r-- | base/plugins.h | 9 |
7 files changed, 28 insertions, 33 deletions
diff --git a/base/engine.cpp b/base/engine.cpp index f64b1ec68c..a01a7df533 100644 --- a/base/engine.cpp +++ b/base/engine.cpp @@ -24,7 +24,6 @@ #include <malloc.h> #endif #include "base/engine.h" -#include "base/gameDetector.h" #include "common/config-manager.h" #include "common/file.h" #include "common/timer.h" @@ -37,7 +36,9 @@ Engine *g_engine = 0; Engine::Engine(OSystem *syst) - : _system(syst), _gameDataPath(ConfMan.get("path")) { + : _system(syst), + _gameDataPath(ConfMan.get("path")), + _targetName(ConfMan.getActiveDomainName()){ g_engine = this; _mixer = new Audio::Mixer(); @@ -55,9 +56,9 @@ Engine::~Engine() { g_engine = NULL; } -void Engine::initCommonGFX(GameDetector &detector, bool defaultTo1XScaler) { +void Engine::initCommonGFX(bool defaultTo1XScaler) { const Common::ConfigManager::Domain *transientDomain = ConfMan.getDomain(Common::ConfigManager::kTransientDomain); - const Common::ConfigManager::Domain *gameDomain = ConfMan.getDomain(detector._targetName); + const Common::ConfigManager::Domain *gameDomain = ConfMan.getActiveDomain(); assert(transientDomain); diff --git a/base/engine.h b/base/engine.h index a786a73cc3..6cf4158e15 100644 --- a/base/engine.h +++ b/base/engine.h @@ -25,7 +25,6 @@ #include "common/scummsys.h" #include "common/str.h" -class GameDetector; class OSystem; namespace Audio { class Mixer; @@ -42,6 +41,7 @@ public: Common::Timer * _timer; protected: + const Common::String _targetName; // target name for saves const Common::String _gameDataPath; Common::SaveFileManager *_saveFileMan; @@ -56,7 +56,7 @@ public: * Init the engine. * @return 0 for success, else an error code. */ - virtual int init(GameDetector &detector) = 0; + virtual int init() = 0; /** * Start the main engine loop. @@ -69,7 +69,7 @@ public: /** Specific for each engine: prepare error string. */ virtual void errorString(const char *buf_input, char *buf_output); - void initCommonGFX(GameDetector &detector, bool defaultTo1XScaler); + void initCommonGFX(bool defaultTo1XScaler); /** On some systems, check if the game appears to be run from CD. */ void checkCD(); diff --git a/base/gameDetector.cpp b/base/gameDetector.cpp index ad74752fcf..dbe9e7fb16 100644 --- a/base/gameDetector.cpp +++ b/base/gameDetector.cpp @@ -578,11 +578,10 @@ void GameDetector::processSettings(Common::String &target, Common::StringMap &se void GameDetector::setTarget(const String &target) { - _targetName = target; ConfMan.setActiveDomain(target); // Make sure the gameid is set in the config manager, and that it is lowercase. - String gameid(_targetName); + String gameid(target); if (ConfMan.hasKey("gameid")) gameid = ConfMan.get("gameid"); gameid.toLowercase(); @@ -592,7 +591,7 @@ void GameDetector::setTarget(const String &target) { const Plugin *GameDetector::detectMain() { const Plugin *plugin = 0; - if (_targetName.empty()) { + if (ConfMan.getActiveDomainName().empty()) { warning("No game was specified..."); return 0; } @@ -602,7 +601,7 @@ const Plugin *GameDetector::detectMain() { if (plugin == 0) { printf("Failed game detection\n"); - warning("%s is an invalid target. Use the --list-targets option to list targets", _targetName.c_str()); + warning("%s is an invalid target. Use the --list-targets option to list targets", ConfMan.getActiveDomainName().c_str()); return 0; } diff --git a/base/gameDetector.h b/base/gameDetector.h index dc09262368..1c474a8946 100644 --- a/base/gameDetector.h +++ b/base/gameDetector.h @@ -27,7 +27,6 @@ #include "common/str.h" #include "common/config-manager.h" -class GameDetector; class OSystem; class Plugin; @@ -69,8 +68,6 @@ public: void processSettings(Common::String &target, Common::StringMap &settings); const Plugin *detectMain(); - String _targetName; - public: static GameDescriptor findGame(const String &gameName, const Plugin **plugin = NULL); diff --git a/base/main.cpp b/base/main.cpp index 1b01bdcbd5..b2bae600fe 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -157,7 +157,7 @@ static bool launcherDialog(GameDetector &detector, OSystem &system) { return (dlg.runModal() != -1); } -static int runGame(const Plugin *plugin, GameDetector &detector, OSystem &system, const Common::String &edebuglevels) { +static int runGame(const Plugin *plugin, OSystem &system, const Common::String &edebuglevels) { // We add it here, so MD5-based detection will be able to // read mixed case files if (ConfMan.hasKey("path")) @@ -166,12 +166,12 @@ static int runGame(const Plugin *plugin, GameDetector &detector, OSystem &system Common::File::addDefaultDirectory("."); // Create the game engine - Engine *engine = plugin->createInstance(&detector, &system); + Engine *engine = plugin->createInstance(&system); if (!engine) { // TODO: Show an error dialog or so? //GUI::MessageDialog alert("ScummVM could not find any game in the specified directory!"); //alert.runModal(); - warning("Failed to instantiate engine for target %s", detector._targetName.c_str()); + warning("Failed to instantiate engine for target %s", ConfMan.getActiveDomainName().c_str()); return 0; } @@ -179,13 +179,13 @@ static int runGame(const Plugin *plugin, GameDetector &detector, OSystem &system Common::enableSpecialDebugLevelList(edebuglevels); // Set the window caption to the game name - Common::String caption(ConfMan.get("description", detector._targetName)); + Common::String caption(ConfMan.get("description")); Common::String desc = GameDetector::findGame(ConfMan.get("gameid")).description; if (caption.empty() && !desc.empty()) caption = desc; if (caption.empty()) - caption = detector._targetName; + caption = ConfMan.getActiveDomainName(); // Use the domain (=target) name if (!caption.empty()) { system.setWindowCaption(caption.c_str()); } @@ -208,7 +208,7 @@ static int runGame(const Plugin *plugin, GameDetector &detector, OSystem &system int result; // Init the engine (this might change the screen parameters - result = engine->init(detector); + result = engine->init(); // Run the game engine if the initialization was successful. if (result == 0) { @@ -314,7 +314,7 @@ 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 (ConfMan.getActiveDomainName().empty()) { running = launcherDialog(detector, system); // Discard any command line options. Those that affect the graphics @@ -335,7 +335,7 @@ extern "C" int scummvm_main(int argc, char *argv[]) { // to save memory PluginManager::instance().unloadPluginsExcept(plugin); - int result = runGame(plugin, detector, system, specialDebug); + int result = runGame(plugin, system, specialDebug); if (result == 0) break; diff --git a/base/plugins.cpp b/base/plugins.cpp index 80f19bd775..8cb1e1e6ae 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -23,13 +23,12 @@ #include "common/stdafx.h" #include "backends/fs/fs.h" -#include "base/gameDetector.h" #include "base/plugins.h" #include "base/engine.h" #include "common/util.h" /** Type of factory functions which make new Engine objects. */ -typedef Engine *(*EngineFactory)(GameDetector *detector, OSystem *syst); +typedef Engine *(*EngineFactory)(OSystem *syst); typedef const char *(*NameFunc)(); typedef GameDescriptor (*GameIDQueryFunc)(const char *gameid); @@ -117,9 +116,9 @@ public: const char *getName() const { return _plugin->_name; } - Engine *createInstance(GameDetector *detector, OSystem *syst) const { + Engine *createInstance(OSystem *syst) const { assert(_plugin->_ef); - return (*_plugin->_ef)(detector, syst); + return (*_plugin->_ef)(syst); } GameList getSupportedGames() const { return _plugin->_games; } @@ -158,9 +157,9 @@ public: const char *getName() const { return _name.c_str(); } - Engine *createInstance(GameDetector *detector, OSystem *syst) const { + Engine *createInstance(OSystem *syst) const { assert(_ef); - return (*_ef)(detector, syst); + return (*_ef)(syst); } GameList getSupportedGames() const { return _games; } diff --git a/base/plugins.h b/base/plugins.h index 8e5efcf2ea..5b758221a2 100644 --- a/base/plugins.h +++ b/base/plugins.h @@ -31,7 +31,6 @@ class Engine; class FSList; -class GameDetector; class OSystem; /** List of games. */ @@ -85,7 +84,7 @@ public: virtual GameDescriptor findGame(const char *gameid) const = 0; virtual DetectedGameList detectGames(const FSList &fslist) const = 0; - virtual Engine *createInstance(GameDetector *detector, OSystem *syst) const = 0; + virtual Engine *createInstance(OSystem *syst) const = 0; }; @@ -107,7 +106,7 @@ public: * - DetectedGameList Engine_##ID##_detectGames(const FSList &fslist) * -> scans through the given file list (usually the contents of a directory), * and attempts to detects games present in that location. - * - Engine *Engine_##ID##_create(GameDetector *detector, OSystem *syst) + * - Engine *Engine_##ID##_create(OSystem *syst) * -> factory function, create an instance of the Engine class. * * @todo add some means to query the plugin API version etc. @@ -131,7 +130,7 @@ public: PLUGIN_EXPORT const char *PLUGIN_name() { return name; } \ PLUGIN_EXPORT GameList PLUGIN_gameIDList() { return Engine_##ID##_gameIDList(); } \ PLUGIN_EXPORT GameDescriptor PLUGIN_findGameID(const char *gameid) { return Engine_##ID##_findGameID(gameid); } \ - PLUGIN_EXPORT Engine *PLUGIN_createEngine(GameDetector *detector, OSystem *syst) { return Engine_##ID##_create(detector, syst); } \ + PLUGIN_EXPORT Engine *PLUGIN_createEngine(OSystem *syst) { return Engine_##ID##_create(syst); } \ PLUGIN_EXPORT DetectedGameList PLUGIN_detectGames(const FSList &fslist) { return Engine_##ID##_detectGames(fslist); } \ } \ void dummyFuncToAllowTrailingSemicolon() @@ -146,7 +145,7 @@ class PluginRegistrator { friend class StaticPlugin; public: typedef GameDescriptor (*GameIDQueryFunc)(const char *gameid); - typedef Engine *(*EngineFactory)(GameDetector *detector, OSystem *syst); + typedef Engine *(*EngineFactory)(OSystem *syst); typedef DetectedGameList (*DetectFunc)(const FSList &fslist); protected: |