diff options
author | Max Horn | 2003-12-21 15:29:52 +0000 |
---|---|---|
committer | Max Horn | 2003-12-21 15:29:52 +0000 |
commit | f19f73eb5069b4f092714535e77efc0d6881c612 (patch) | |
tree | ee5e418571bb6ebdb8bb6b8e72cb926ef31f2bd7 | |
parent | 7b498fe7db91fa3e52d2c69bc9980f4609acc288 (diff) | |
download | scummvm-rg350-f19f73eb5069b4f092714535e77efc0d6881c612.tar.gz scummvm-rg350-f19f73eb5069b4f092714535e77efc0d6881c612.tar.bz2 scummvm-rg350-f19f73eb5069b4f092714535e77efc0d6881c612.zip |
Make it possible for game detection functions to detect language/platform (not yet done by any detector, but will come with the MD5 detection code)
svn-id: r11811
-rw-r--r-- | base/gameDetector.cpp | 2 | ||||
-rw-r--r-- | base/gameDetector.h | 2 | ||||
-rw-r--r-- | base/plugins.cpp | 19 | ||||
-rw-r--r-- | base/plugins.h | 29 | ||||
-rw-r--r-- | gui/launcher.cpp | 22 | ||||
-rw-r--r-- | queen/queen.cpp | 4 | ||||
-rw-r--r-- | scumm/scummvm.cpp | 4 | ||||
-rw-r--r-- | simon/simon.cpp | 4 | ||||
-rw-r--r-- | sky/sky.cpp | 6 | ||||
-rw-r--r-- | sword1/sword1.cpp | 4 | ||||
-rw-r--r-- | sword2/sword2.cpp | 4 |
11 files changed, 68 insertions, 32 deletions
diff --git a/base/gameDetector.cpp b/base/gameDetector.cpp index 79e8ca9eee..7dabde7f39 100644 --- a/base/gameDetector.cpp +++ b/base/gameDetector.cpp @@ -158,7 +158,7 @@ GameDetector::GameDetector() { ConfMan.registerDefault("platform", Common::kPlatformPC); ConfMan.registerDefault("language", "en"); // ConfMan.registerDefault("nosubtitles", false); - ConfMan.registerDefault("subtitles", false); + ConfMan.registerDefault("subtitles", true); ConfMan.registerDefault("boot_param", 0); ConfMan.registerDefault("save_slot", -1); diff --git a/base/gameDetector.h b/base/gameDetector.h index e6cf2b3ace..903aaed508 100644 --- a/base/gameDetector.h +++ b/base/gameDetector.h @@ -34,6 +34,8 @@ class Plugin; /** Global (shared) game feature flags. */ enum { +// GF_HAS_SPEECH = 1 << 29, +// GF_HAS_SUBTITLES = 1 << 30, GF_DEFAULT_TO_1X_SCALER = 1 << 31 }; diff --git a/base/plugins.cpp b/base/plugins.cpp index 9769293a70..7968eb8e00 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -32,7 +32,7 @@ typedef Engine *(*EngineFactory)(GameDetector *detector, OSystem *syst); typedef const char *(*NameFunc)(); typedef GameList (*TargetListFunc)(); -typedef GameList (*DetectFunc)(const FSList &fslist); +typedef DetectedGameList (*DetectFunc)(const FSList &fslist); #ifdef DYNAMIC_MODULES @@ -81,7 +81,7 @@ public: } GameList getSupportedGames() const { return _games; } - GameList detectGames(const FSList &fslist) const { + DetectedGameList detectGames(const FSList &fslist) const { return (*_df)(fslist); } }; @@ -113,7 +113,7 @@ public: } GameList getSupportedGames() const { return _games; } - GameList detectGames(const FSList &fslist) const { + DetectedGameList detectGames(const FSList &fslist) const { assert(_df); return (*_df)(fslist); } @@ -275,3 +275,16 @@ bool PluginManager::tryLoadPlugin(Plugin *plugin) { return false; } } + +DetectedGameList PluginManager::detectGames(const FSList &fslist) const { + DetectedGameList candidates; + + // Iterate over all known games and for each check if it might be + // the game in the presented directory. + PluginList::ConstIterator iter; + for (iter = _plugins.begin(); iter != _plugins.end(); ++iter) { + candidates.push_back((*iter)->detectGames(fslist)); + } + + return candidates; +} diff --git a/base/plugins.h b/base/plugins.h index 3852934e49..7629cac8a0 100644 --- a/base/plugins.h +++ b/base/plugins.h @@ -25,6 +25,7 @@ #include "common/list.h" #include "common/singleton.h" +#include "common/util.h" class Engine; class FSList; @@ -32,10 +33,28 @@ class GameDetector; class OSystem; struct GameSettings; -/** List of GameSettings- */ +/** List of games. */ typedef Common::List<GameSettings> GameList; /** + * A detected game. Carries the GameSettings, but also (optionally) + * information about the language and platform of the detected game. + */ +struct DetectedGame : GameSettings { + Common::Language language; + Common::Platform platform; + DetectedGame() : language(Common::UNK_LANG), platform(Common::kPlatformUnknown) {} + DetectedGame(const GameSettings &game, + Common::Language l = Common::UNK_LANG, + Common::Platform p = Common::kPlatformUnknown) + : GameSettings(game), language(l), platform(p) {} +}; + +/** List of detected games. */ +typedef Common::List<DetectedGame> DetectedGameList; + + +/** * Abstract base class for the plugin system. * Subclasses for this can be used to wrap both static and dynamic * plugins. @@ -52,7 +71,7 @@ public: virtual GameList getSupportedGames() const = 0; virtual GameSettings findGame(const char *gameName) const; - virtual GameList detectGames(const FSList &fslist) const = 0; + virtual DetectedGameList detectGames(const FSList &fslist) const = 0; virtual Engine *createInstance(GameDetector *detector, OSystem *syst) const = 0; }; @@ -75,7 +94,7 @@ public: const char *PLUGIN_name() { return name; } \ GameList PLUGIN_getSupportedGames() { return gameListFactory(); } \ Engine *PLUGIN_createEngine(GameDetector *detector, OSystem *syst) { return engineFactory(detector, syst); } \ - GameList PLUGIN_detectGames(const FSList &fslist) { return detectGames(fslist); } \ + DetectedGameList PLUGIN_detectGames(const FSList &fslist) { return detectGames(fslist); } \ } #endif @@ -106,6 +125,8 @@ public: void unloadPlugins(); const PluginList &getPlugins() { return _plugins; } + + DetectedGameList detectGames(const FSList &fslist) const; }; @@ -114,7 +135,7 @@ public: #define DECLARE_PLUGIN(name) \ extern GameList Engine_##name##_gameList(); \ extern Engine *Engine_##name##_create(GameDetector *detector, OSystem *syst); \ - extern GameList Engine_##name##_detectGames(const FSList &fslist); + extern DetectedGameList Engine_##name##_detectGames(const FSList &fslist); // Factory functions => no need to include the specific classes // in this header. This serves two purposes: diff --git a/gui/launcher.cpp b/gui/launcher.cpp index a105234e41..ad4feb27cb 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -403,15 +403,7 @@ void LauncherDialog::addGame() { // ...so let's determine a list of candidates, games that // could be contained in the specified directory. - GameList candidates; - - // Iterate over all known games and for each check if it might be - // the game in the presented directory. - const PluginList &plugins = PluginManager::instance().getPlugins(); - PluginList::ConstIterator iter = plugins.begin(); - for (iter = plugins.begin(); iter != plugins.end(); ++iter) { - candidates.push_back((*iter)->detectGames(*files)); - } + DetectedGameList candidates(PluginManager::instance().detectGames(*files)); int idx; if (candidates.isEmpty()) { @@ -433,7 +425,7 @@ void LauncherDialog::addGame() { idx = dialog.runModal(); } if (0 <= idx && idx < candidates.size()) { - GameSettings result = candidates[idx]; + DetectedGame result = candidates[idx]; // The auto detector or the user made a choice. // Pick a domain name which does not yet exist (after all, we @@ -453,6 +445,14 @@ void LauncherDialog::addGame() { } ConfMan.set("path", dir->path(), domain); + // Set language if specified + if (result.language != Common::UNK_LANG) + ConfMan.set("language", Common::getLanguageString(result.language), domain); + + // Set platform if specified + if (result.platform != Common::kPlatformUnknown) + ConfMan.set("platform", Common::getPlatformString(result.platform), domain); + // Display edit dialog for the new entry EditGameDialog editDialog(domain, result); if (editDialog.runModal()) { @@ -460,7 +460,7 @@ void LauncherDialog::addGame() { // Write config to disk ConfMan.flushToDisk(); - + // Update the ListWidget and force a redraw updateListing(); draw(); diff --git a/queen/queen.cpp b/queen/queen.cpp index 60a2f74c0d..235ecafabe 100644 --- a/queen/queen.cpp +++ b/queen/queen.cpp @@ -62,8 +62,8 @@ GameList Engine_QUEEN_gameList() { return games; } -GameList Engine_QUEEN_detectGames(const FSList &fslist) { - GameList detectedGames; +DetectedGameList Engine_QUEEN_detectGames(const FSList &fslist) { + DetectedGameList detectedGames; // Iterate over all files in the given directory for (FSList::ConstIterator file = fslist.begin(); file != fslist.end(); ++file) { diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index fb1261daba..46db749c42 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -2866,8 +2866,8 @@ GameList Engine_SCUMM_gameList() { return games; } -GameList Engine_SCUMM_detectGames(const FSList &fslist) { - GameList detectedGames; +DetectedGameList Engine_SCUMM_detectGames(const FSList &fslist) { + DetectedGameList detectedGames; const ScummGameSettings *g; char detectName[128]; char detectName2[128]; diff --git a/simon/simon.cpp b/simon/simon.cpp index 84fd04fa0e..cdfb09a83f 100644 --- a/simon/simon.cpp +++ b/simon/simon.cpp @@ -90,8 +90,8 @@ GameList Engine_SIMON_gameList() { return games; } -GameList Engine_SIMON_detectGames(const FSList &fslist) { - GameList detectedGames; +DetectedGameList Engine_SIMON_detectGames(const FSList &fslist) { + DetectedGameList detectedGames; const SimonGameSettings *g; char detectName[128]; char detectName2[128]; diff --git a/sky/sky.cpp b/sky/sky.cpp index 68158436d1..c82675a498 100644 --- a/sky/sky.cpp +++ b/sky/sky.cpp @@ -87,8 +87,8 @@ GameList Engine_SKY_gameList() { return games; } -GameList Engine_SKY_detectGames(const FSList &fslist) { - GameList detectedGames; +DetectedGameList Engine_SKY_detectGames(const FSList &fslist) { + DetectedGameList detectedGames; // Iterate over all files in the given directory for (FSList::ConstIterator file = fslist.begin(); file != fslist.end(); ++file) { const char *fileName = file->displayName().c_str(); @@ -271,7 +271,7 @@ void SkyEngine::initialise(void) { _systemVars.systemFlags |= SF_ALLOW_SPEECH; if (ConfMan.hasKey("nosubtitles")) { warning("Configuration key 'nosubtitles' is deprecated. Use 'subtitles' instead"); - if (ConfMan.getBool("nosubtitles") == false) + if (!ConfMan.getBool("nosubtitles")) _systemVars.systemFlags |= SF_ALLOW_TEXT; } diff --git a/sword1/sword1.cpp b/sword1/sword1.cpp index 025ff7aeb0..7f68e95a98 100644 --- a/sword1/sword1.cpp +++ b/sword1/sword1.cpp @@ -51,8 +51,8 @@ GameList Engine_SWORD1_gameList() { return games; } -GameList Engine_SWORD1_detectGames(const FSList &fslist) { - GameList detectedGames; +DetectedGameList Engine_SWORD1_detectGames(const FSList &fslist) { + DetectedGameList detectedGames; // Iterate over all files in the given directory for (FSList::ConstIterator file = fslist.begin(); file != fslist.end(); ++file) { diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp index 2b987eb121..b976592cea 100644 --- a/sword2/sword2.cpp +++ b/sword2/sword2.cpp @@ -60,8 +60,8 @@ GameList Engine_SWORD2_gameList() { return games; } -GameList Engine_SWORD2_detectGames(const FSList &fslist) { - GameList detectedGames; +DetectedGameList Engine_SWORD2_detectGames(const FSList &fslist) { + DetectedGameList detectedGames; const Sword2GameSettings *g; // TODO: It would be nice if we had code here which distinguishes |