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("platform", Common::kPlatformPC);
|
||||||
ConfMan.registerDefault("language", "en");
|
ConfMan.registerDefault("language", "en");
|
||||||
// ConfMan.registerDefault("nosubtitles", false);
|
// ConfMan.registerDefault("nosubtitles", false);
|
||||||
ConfMan.registerDefault("subtitles", false);
|
ConfMan.registerDefault("subtitles", true);
|
||||||
ConfMan.registerDefault("boot_param", 0);
|
ConfMan.registerDefault("boot_param", 0);
|
||||||
ConfMan.registerDefault("save_slot", -1);
|
ConfMan.registerDefault("save_slot", -1);
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@ class Plugin;
|
||||||
|
|
||||||
/** Global (shared) game feature flags. */
|
/** Global (shared) game feature flags. */
|
||||||
enum {
|
enum {
|
||||||
|
// GF_HAS_SPEECH = 1 << 29,
|
||||||
|
// GF_HAS_SUBTITLES = 1 << 30,
|
||||||
GF_DEFAULT_TO_1X_SCALER = 1 << 31
|
GF_DEFAULT_TO_1X_SCALER = 1 << 31
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ typedef Engine *(*EngineFactory)(GameDetector *detector, OSystem *syst);
|
||||||
|
|
||||||
typedef const char *(*NameFunc)();
|
typedef const char *(*NameFunc)();
|
||||||
typedef GameList (*TargetListFunc)();
|
typedef GameList (*TargetListFunc)();
|
||||||
typedef GameList (*DetectFunc)(const FSList &fslist);
|
typedef DetectedGameList (*DetectFunc)(const FSList &fslist);
|
||||||
|
|
||||||
|
|
||||||
#ifdef DYNAMIC_MODULES
|
#ifdef DYNAMIC_MODULES
|
||||||
|
@ -81,7 +81,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
GameList getSupportedGames() const { return _games; }
|
GameList getSupportedGames() const { return _games; }
|
||||||
GameList detectGames(const FSList &fslist) const {
|
DetectedGameList detectGames(const FSList &fslist) const {
|
||||||
return (*_df)(fslist);
|
return (*_df)(fslist);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -113,7 +113,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
GameList getSupportedGames() const { return _games; }
|
GameList getSupportedGames() const { return _games; }
|
||||||
GameList detectGames(const FSList &fslist) const {
|
DetectedGameList detectGames(const FSList &fslist) const {
|
||||||
assert(_df);
|
assert(_df);
|
||||||
return (*_df)(fslist);
|
return (*_df)(fslist);
|
||||||
}
|
}
|
||||||
|
@ -275,3 +275,16 @@ bool PluginManager::tryLoadPlugin(Plugin *plugin) {
|
||||||
return false;
|
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/list.h"
|
||||||
#include "common/singleton.h"
|
#include "common/singleton.h"
|
||||||
|
#include "common/util.h"
|
||||||
|
|
||||||
class Engine;
|
class Engine;
|
||||||
class FSList;
|
class FSList;
|
||||||
|
@ -32,9 +33,27 @@ class GameDetector;
|
||||||
class OSystem;
|
class OSystem;
|
||||||
struct GameSettings;
|
struct GameSettings;
|
||||||
|
|
||||||
/** List of GameSettings- */
|
/** List of games. */
|
||||||
typedef Common::List<GameSettings> GameList;
|
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.
|
* Abstract base class for the plugin system.
|
||||||
* Subclasses for this can be used to wrap both static and dynamic
|
* Subclasses for this can be used to wrap both static and dynamic
|
||||||
|
@ -52,7 +71,7 @@ public:
|
||||||
|
|
||||||
virtual GameList getSupportedGames() const = 0;
|
virtual GameList getSupportedGames() const = 0;
|
||||||
virtual GameSettings findGame(const char *gameName) const;
|
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;
|
virtual Engine *createInstance(GameDetector *detector, OSystem *syst) const = 0;
|
||||||
};
|
};
|
||||||
|
@ -75,7 +94,7 @@ public:
|
||||||
const char *PLUGIN_name() { return name; } \
|
const char *PLUGIN_name() { return name; } \
|
||||||
GameList PLUGIN_getSupportedGames() { return gameListFactory(); } \
|
GameList PLUGIN_getSupportedGames() { return gameListFactory(); } \
|
||||||
Engine *PLUGIN_createEngine(GameDetector *detector, OSystem *syst) { return engineFactory(detector, syst); } \
|
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
|
#endif
|
||||||
|
|
||||||
|
@ -106,6 +125,8 @@ public:
|
||||||
void unloadPlugins();
|
void unloadPlugins();
|
||||||
|
|
||||||
const PluginList &getPlugins() { return _plugins; }
|
const PluginList &getPlugins() { return _plugins; }
|
||||||
|
|
||||||
|
DetectedGameList detectGames(const FSList &fslist) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,7 +135,7 @@ public:
|
||||||
#define DECLARE_PLUGIN(name) \
|
#define DECLARE_PLUGIN(name) \
|
||||||
extern GameList Engine_##name##_gameList(); \
|
extern GameList Engine_##name##_gameList(); \
|
||||||
extern Engine *Engine_##name##_create(GameDetector *detector, OSystem *syst); \
|
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
|
// Factory functions => no need to include the specific classes
|
||||||
// in this header. This serves two purposes:
|
// in this header. This serves two purposes:
|
||||||
|
|
|
@ -403,15 +403,7 @@ void LauncherDialog::addGame() {
|
||||||
|
|
||||||
// ...so let's determine a list of candidates, games that
|
// ...so let's determine a list of candidates, games that
|
||||||
// could be contained in the specified directory.
|
// could be contained in the specified directory.
|
||||||
GameList candidates;
|
DetectedGameList candidates(PluginManager::instance().detectGames(*files));
|
||||||
|
|
||||||
// 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));
|
|
||||||
}
|
|
||||||
|
|
||||||
int idx;
|
int idx;
|
||||||
if (candidates.isEmpty()) {
|
if (candidates.isEmpty()) {
|
||||||
|
@ -433,7 +425,7 @@ void LauncherDialog::addGame() {
|
||||||
idx = dialog.runModal();
|
idx = dialog.runModal();
|
||||||
}
|
}
|
||||||
if (0 <= idx && idx < candidates.size()) {
|
if (0 <= idx && idx < candidates.size()) {
|
||||||
GameSettings result = candidates[idx];
|
DetectedGame result = candidates[idx];
|
||||||
|
|
||||||
// The auto detector or the user made a choice.
|
// The auto detector or the user made a choice.
|
||||||
// Pick a domain name which does not yet exist (after all, we
|
// 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);
|
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
|
// Display edit dialog for the new entry
|
||||||
EditGameDialog editDialog(domain, result);
|
EditGameDialog editDialog(domain, result);
|
||||||
if (editDialog.runModal()) {
|
if (editDialog.runModal()) {
|
||||||
|
@ -460,7 +460,7 @@ void LauncherDialog::addGame() {
|
||||||
|
|
||||||
// Write config to disk
|
// Write config to disk
|
||||||
ConfMan.flushToDisk();
|
ConfMan.flushToDisk();
|
||||||
|
|
||||||
// Update the ListWidget and force a redraw
|
// Update the ListWidget and force a redraw
|
||||||
updateListing();
|
updateListing();
|
||||||
draw();
|
draw();
|
||||||
|
|
|
@ -62,8 +62,8 @@ GameList Engine_QUEEN_gameList() {
|
||||||
return games;
|
return games;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameList Engine_QUEEN_detectGames(const FSList &fslist) {
|
DetectedGameList Engine_QUEEN_detectGames(const FSList &fslist) {
|
||||||
GameList detectedGames;
|
DetectedGameList detectedGames;
|
||||||
|
|
||||||
// Iterate over all files in the given directory
|
// Iterate over all files in the given directory
|
||||||
for (FSList::ConstIterator file = fslist.begin(); file != fslist.end(); ++file) {
|
for (FSList::ConstIterator file = fslist.begin(); file != fslist.end(); ++file) {
|
||||||
|
|
|
@ -2866,8 +2866,8 @@ GameList Engine_SCUMM_gameList() {
|
||||||
return games;
|
return games;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameList Engine_SCUMM_detectGames(const FSList &fslist) {
|
DetectedGameList Engine_SCUMM_detectGames(const FSList &fslist) {
|
||||||
GameList detectedGames;
|
DetectedGameList detectedGames;
|
||||||
const ScummGameSettings *g;
|
const ScummGameSettings *g;
|
||||||
char detectName[128];
|
char detectName[128];
|
||||||
char detectName2[128];
|
char detectName2[128];
|
||||||
|
|
|
@ -90,8 +90,8 @@ GameList Engine_SIMON_gameList() {
|
||||||
return games;
|
return games;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameList Engine_SIMON_detectGames(const FSList &fslist) {
|
DetectedGameList Engine_SIMON_detectGames(const FSList &fslist) {
|
||||||
GameList detectedGames;
|
DetectedGameList detectedGames;
|
||||||
const SimonGameSettings *g;
|
const SimonGameSettings *g;
|
||||||
char detectName[128];
|
char detectName[128];
|
||||||
char detectName2[128];
|
char detectName2[128];
|
||||||
|
|
|
@ -87,8 +87,8 @@ GameList Engine_SKY_gameList() {
|
||||||
return games;
|
return games;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameList Engine_SKY_detectGames(const FSList &fslist) {
|
DetectedGameList Engine_SKY_detectGames(const FSList &fslist) {
|
||||||
GameList detectedGames;
|
DetectedGameList detectedGames;
|
||||||
// Iterate over all files in the given directory
|
// Iterate over all files in the given directory
|
||||||
for (FSList::ConstIterator file = fslist.begin(); file != fslist.end(); ++file) {
|
for (FSList::ConstIterator file = fslist.begin(); file != fslist.end(); ++file) {
|
||||||
const char *fileName = file->displayName().c_str();
|
const char *fileName = file->displayName().c_str();
|
||||||
|
@ -271,7 +271,7 @@ void SkyEngine::initialise(void) {
|
||||||
_systemVars.systemFlags |= SF_ALLOW_SPEECH;
|
_systemVars.systemFlags |= SF_ALLOW_SPEECH;
|
||||||
if (ConfMan.hasKey("nosubtitles")) {
|
if (ConfMan.hasKey("nosubtitles")) {
|
||||||
warning("Configuration key 'nosubtitles' is deprecated. Use 'subtitles' instead");
|
warning("Configuration key 'nosubtitles' is deprecated. Use 'subtitles' instead");
|
||||||
if (ConfMan.getBool("nosubtitles") == false)
|
if (!ConfMan.getBool("nosubtitles"))
|
||||||
_systemVars.systemFlags |= SF_ALLOW_TEXT;
|
_systemVars.systemFlags |= SF_ALLOW_TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,8 @@ GameList Engine_SWORD1_gameList() {
|
||||||
return games;
|
return games;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameList Engine_SWORD1_detectGames(const FSList &fslist) {
|
DetectedGameList Engine_SWORD1_detectGames(const FSList &fslist) {
|
||||||
GameList detectedGames;
|
DetectedGameList detectedGames;
|
||||||
|
|
||||||
// Iterate over all files in the given directory
|
// Iterate over all files in the given directory
|
||||||
for (FSList::ConstIterator file = fslist.begin(); file != fslist.end(); ++file) {
|
for (FSList::ConstIterator file = fslist.begin(); file != fslist.end(); ++file) {
|
||||||
|
|
|
@ -60,8 +60,8 @@ GameList Engine_SWORD2_gameList() {
|
||||||
return games;
|
return games;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameList Engine_SWORD2_detectGames(const FSList &fslist) {
|
DetectedGameList Engine_SWORD2_detectGames(const FSList &fslist) {
|
||||||
GameList detectedGames;
|
DetectedGameList detectedGames;
|
||||||
const Sword2GameSettings *g;
|
const Sword2GameSettings *g;
|
||||||
|
|
||||||
// TODO: It would be nice if we had code here which distinguishes
|
// TODO: It would be nice if we had code here which distinguishes
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue