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
This commit is contained in:
parent
7b498fe7db
commit
f19f73eb50
11 changed files with 68 additions and 32 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "common/list.h"
|
||||
#include "common/singleton.h"
|
||||
#include "common/util.h"
|
||||
|
||||
class Engine;
|
||||
class FSList;
|
||||
|
@ -32,9 +33,27 @@ 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
|
||||
|
@ -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:
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue