mirror of
https://github.com/libretro/scummvm.git
synced 2024-11-27 11:20:40 +00:00
First phase of detection-related plugins interface improvements. Now plugins
return StringMap instead of fixed list of parameters. This adds great flexibility. Current patch should not alter any functionality, i.e. if there are regressions, submit a report. Phase 2 will benefit from these changes and will come later. svn-id: r25134
This commit is contained in:
parent
47b1321d15
commit
cd8a5f3a98
@ -34,7 +34,7 @@ typedef PluginError (*EngineFactory)(OSystem *syst, Engine **engine);
|
||||
typedef const char *(*NameFunc)();
|
||||
typedef GameDescriptor (*GameIDQueryFunc)(const char *gameid);
|
||||
typedef GameList (*GameIDListFunc)();
|
||||
typedef DetectedGameList (*DetectFunc)(const FSList &fslist);
|
||||
typedef GameList (*DetectFunc)(const FSList &fslist);
|
||||
|
||||
|
||||
class DynamicPlugin : public Plugin {
|
||||
@ -68,7 +68,7 @@ public:
|
||||
return (*_qf)(gameid);
|
||||
}
|
||||
|
||||
DetectedGameList detectGames(const FSList &fslist) const {
|
||||
GameList detectGames(const FSList &fslist) const {
|
||||
assert(_df);
|
||||
return (*_df)(fslist);
|
||||
}
|
||||
|
@ -527,7 +527,7 @@ static void listGames() {
|
||||
for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
|
||||
GameList list = (*iter)->getSupportedGames();
|
||||
for (GameList::iterator v = list.begin(); v != list.end(); ++v) {
|
||||
printf("%-20s %s\n", v->gameid.c_str(), v->description.c_str());
|
||||
printf("%-20s %s\n", v->gameid().c_str(), v->description().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -550,8 +550,8 @@ static void listTargets() {
|
||||
// be taken into account, too.
|
||||
Common::String gameid(name);
|
||||
GameDescriptor g = Base::findGame(gameid);
|
||||
if (g.description.size() > 0)
|
||||
description = g.description;
|
||||
if (g["description"].size() > 0)
|
||||
description = g["description"];
|
||||
}
|
||||
|
||||
printf("%-20s %s\n", name.c_str(), description.c_str());
|
||||
@ -589,11 +589,11 @@ static void runDetectorTest() {
|
||||
continue;
|
||||
}
|
||||
|
||||
DetectedGameList candidates(PluginManager::instance().detectGames(files));
|
||||
GameList candidates(PluginManager::instance().detectGames(files));
|
||||
bool gameidDiffers = false;
|
||||
DetectedGameList::iterator x;
|
||||
GameList::iterator x;
|
||||
for (x = candidates.begin(); x != candidates.end(); ++x) {
|
||||
gameidDiffers |= (scumm_stricmp(gameid.c_str(), x->gameid.c_str()) != 0);
|
||||
gameidDiffers |= (scumm_stricmp(gameid.c_str(), x->gameid().c_str()) != 0);
|
||||
}
|
||||
|
||||
if (candidates.empty()) {
|
||||
@ -616,10 +616,10 @@ static void runDetectorTest() {
|
||||
|
||||
for (x = candidates.begin(); x != candidates.end(); ++x) {
|
||||
printf(" gameid '%s', desc '%s', language '%s', platform '%s'\n",
|
||||
x->gameid.c_str(),
|
||||
x->description.c_str(),
|
||||
Common::getLanguageCode(x->language),
|
||||
Common::getPlatformCode(x->platform));
|
||||
x->gameid().c_str(),
|
||||
x->description().c_str(),
|
||||
Common::getLanguageCode(x->language()),
|
||||
Common::getPlatformCode(x->platform()));
|
||||
}
|
||||
}
|
||||
int total = domains.size();
|
||||
@ -666,7 +666,7 @@ bool processSettings(Common::String &command, Common::StringMap &settings) {
|
||||
// domain (i.e. a target) matching this argument, or alternatively
|
||||
// whether there is a gameid matching that name.
|
||||
if (!command.empty()) {
|
||||
if (ConfMan.hasGameDomain(command) || Base::findGame(command).gameid.size() > 0) {
|
||||
if (ConfMan.hasGameDomain(command) || Base::findGame(command)["gameid"].size() > 0) {
|
||||
ConfMan.setActiveDomain(command);
|
||||
} else {
|
||||
usage("Unrecognized game target '%s'", command.c_str());
|
||||
|
43
base/game.h
43
base/game.h
@ -26,32 +26,41 @@
|
||||
|
||||
#include "common/str.h"
|
||||
#include "common/array.h"
|
||||
#include "common/hash-str.h"
|
||||
|
||||
struct PlainGameDescriptor {
|
||||
const char *gameid;
|
||||
const char *description; // TODO: Rename this to "title" or so
|
||||
};
|
||||
|
||||
struct GameDescriptor {
|
||||
Common::String gameid;
|
||||
Common::String description; // TODO: Rename this to "title" or so
|
||||
|
||||
class GameDescriptor : public Common::StringMap {
|
||||
public:
|
||||
GameDescriptor() {}
|
||||
GameDescriptor(Common::String g, Common::String d) :
|
||||
gameid(g), description(d) {}
|
||||
|
||||
GameDescriptor(const PlainGameDescriptor &pgd) {
|
||||
this->operator []("gameid") = pgd.gameid;
|
||||
this->operator []("description") = pgd.description;
|
||||
}
|
||||
|
||||
GameDescriptor(Common::String g, Common::String d, Common::Language l = Common::UNK_LANG,
|
||||
Common::Platform p = Common::kPlatformUnknown) {
|
||||
this->operator []("gameid") = g;
|
||||
this->operator []("description") = d;
|
||||
if (l != Common::UNK_LANG)
|
||||
this->operator []("language") = Common::getLanguageCode(l);
|
||||
if (p != Common::kPlatformUnknown)
|
||||
this->operator []("platform") = Common::getPlatformCode(p);
|
||||
}
|
||||
|
||||
/**
|
||||
* This template constructor allows to easily convert structs that mimic
|
||||
* GameDescriptor to a real GameDescriptor instance.
|
||||
*
|
||||
* Normally, one would just subclass GameDescriptor to get this effect much easier.
|
||||
* However, subclassing a struct turns it into a non-POD type. One of the
|
||||
* consequences is that you can't have inline intialized arrays of that type.
|
||||
* But we heavily rely on those, hence we can't subclass GameDescriptor...
|
||||
* Update the description string by appending (LANG/PLATFORM/EXTRA) to it.
|
||||
*/
|
||||
template <class T>
|
||||
GameDescriptor(const T &g) :
|
||||
gameid(g.gameid), description(g.description) {}
|
||||
void updateDesc(const char *extra = 0);
|
||||
|
||||
Common::String &gameid() { return this->operator []("gameid"); }
|
||||
Common::String &description() { return this->operator []("description"); }
|
||||
Common::Language language() { return Common::parseLanguage(this->operator []("language")); }
|
||||
Common::Platform platform() { return Common::parsePlatform(this->operator []("platform")); }
|
||||
};
|
||||
|
||||
/** List of games. */
|
||||
@ -61,7 +70,7 @@ public:
|
||||
GameList(const GameList &list) : Common::Array<GameDescriptor>(list) {}
|
||||
GameList(const PlainGameDescriptor *g) {
|
||||
while (g->gameid) {
|
||||
push_back(*g);
|
||||
push_back(GameDescriptor(g->gameid, g->description));
|
||||
g++;
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ GameDescriptor findGame(const Common::String &gameName, const Plugin **plugin) {
|
||||
PluginList::const_iterator iter = plugins.begin();
|
||||
for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
|
||||
result = (*iter)->findGame(gameName.c_str());
|
||||
if (!result.gameid.empty()) {
|
||||
if (!result.gameid().empty()) {
|
||||
if (plugin)
|
||||
*plugin = *iter;
|
||||
break;
|
||||
@ -126,7 +126,7 @@ static const Plugin *detectMain() {
|
||||
}
|
||||
|
||||
// FIXME: Do we really need this one?
|
||||
printf("Trying to start game '%s'\n", game.description.c_str());
|
||||
printf("Trying to start game '%s'\n", game.description().c_str());
|
||||
|
||||
return plugin;
|
||||
}
|
||||
@ -191,7 +191,7 @@ static int runGame(const Plugin *plugin, OSystem &system, const Common::String &
|
||||
// Set the window caption to the game name
|
||||
Common::String caption(ConfMan.get("description"));
|
||||
|
||||
Common::String desc = Base::findGame(ConfMan.get("gameid")).description;
|
||||
Common::String desc = Base::findGame(ConfMan.get("gameid")).description();
|
||||
if (caption.empty() && !desc.empty())
|
||||
caption = desc;
|
||||
if (caption.empty())
|
||||
|
@ -25,30 +25,33 @@
|
||||
#include "common/util.h"
|
||||
|
||||
|
||||
void DetectedGame::updateDesc(const char *extra) {
|
||||
void GameDescriptor::updateDesc(const char *extra) {
|
||||
// TODO: The format used here (LANG/PLATFORM/EXTRA) is not set in stone.
|
||||
// We may want to change the order (PLATFORM/EXTRA/LANG, anybody?), or
|
||||
// the seperator (instead of '/' use ', ' or ' ').
|
||||
const bool hasCustomLanguage = (language != Common::UNK_LANG);
|
||||
const bool hasCustomPlatform = (platform != Common::kPlatformUnknown);
|
||||
const bool hasCustomLanguage = (this->contains("language") && (this->language() != Common::UNK_LANG));
|
||||
const bool hasCustomPlatform = (this->contains("platform") && (this->platform() != Common::kPlatformUnknown));
|
||||
const bool hasExtraDesc = (extra && extra[0]);
|
||||
|
||||
// Adapt the description string if custom platform/language is set.
|
||||
if (hasCustomLanguage || hasCustomPlatform || hasExtraDesc) {
|
||||
description += " (";
|
||||
Common::String descr = this->description();
|
||||
|
||||
descr += " (";
|
||||
if (hasCustomLanguage)
|
||||
description += Common::getLanguageDescription(language);
|
||||
descr += Common::getLanguageDescription(this->language());
|
||||
if (hasCustomPlatform) {
|
||||
if (hasCustomLanguage)
|
||||
description += "/";
|
||||
description += Common::getPlatformDescription(platform);
|
||||
descr += "/";
|
||||
descr += Common::getPlatformDescription(this->platform());
|
||||
}
|
||||
if (hasExtraDesc) {
|
||||
if (hasCustomPlatform || hasCustomLanguage)
|
||||
description += "/";
|
||||
description += extra;
|
||||
descr += "/";
|
||||
descr += extra;
|
||||
}
|
||||
description += ")";
|
||||
descr += ")";
|
||||
this->operator []("description") = descr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +89,7 @@ public:
|
||||
return (*_plugin->_qf)(gameid);
|
||||
}
|
||||
|
||||
DetectedGameList detectGames(const FSList &fslist) const {
|
||||
GameList detectGames(const FSList &fslist) const {
|
||||
assert(_plugin->_df);
|
||||
return (*_plugin->_df)(fslist);
|
||||
}
|
||||
@ -247,8 +250,8 @@ bool PluginManager::tryLoadPlugin(Plugin *plugin) {
|
||||
}
|
||||
}
|
||||
|
||||
DetectedGameList PluginManager::detectGames(const FSList &fslist) const {
|
||||
DetectedGameList candidates;
|
||||
GameList PluginManager::detectGames(const FSList &fslist) const {
|
||||
GameList candidates;
|
||||
|
||||
// Iterate over all known games and for each check if it might be
|
||||
// the game in the presented directory.
|
||||
|
@ -35,35 +35,6 @@ class Engine;
|
||||
class FSList;
|
||||
class OSystem;
|
||||
|
||||
/**
|
||||
* A detected game. Carries the GameDescriptor, but also (optionally)
|
||||
* information about the language and platform of the detected game.
|
||||
*/
|
||||
struct DetectedGame : public GameDescriptor {
|
||||
Common::Language language;
|
||||
Common::Platform platform;
|
||||
DetectedGame(const char *g = 0, const char *d = 0,
|
||||
Common::Language l = Common::UNK_LANG,
|
||||
Common::Platform p = Common::kPlatformUnknown)
|
||||
: GameDescriptor(g, d), language(l), platform(p) {}
|
||||
|
||||
template <class T>
|
||||
DetectedGame(const T &game,
|
||||
Common::Language l = Common::UNK_LANG,
|
||||
Common::Platform p = Common::kPlatformUnknown)
|
||||
: GameDescriptor(game.gameid, game.description), language(l), platform(p) {}
|
||||
|
||||
/**
|
||||
* Update the description string by appending (LANG/PLATFORM/EXTRA) to it.
|
||||
*/
|
||||
void updateDesc(const char *extra = 0);
|
||||
};
|
||||
|
||||
|
||||
/** List of detected games. */
|
||||
typedef Common::Array<DetectedGame> DetectedGameList;
|
||||
|
||||
|
||||
/**
|
||||
* Error codes which mayb be reported by plugins under various circumstances.
|
||||
* @todo Turn this into a global 'ErrorCode' enum used by all of ScummVM ?
|
||||
@ -96,7 +67,7 @@ public:
|
||||
|
||||
virtual GameList getSupportedGames() const = 0;
|
||||
virtual GameDescriptor findGame(const char *gameid) const = 0;
|
||||
virtual DetectedGameList detectGames(const FSList &fslist) const = 0;
|
||||
virtual GameList detectGames(const FSList &fslist) const = 0;
|
||||
|
||||
virtual PluginError createInstance(OSystem *syst, Engine **engine) const = 0;
|
||||
};
|
||||
@ -146,7 +117,7 @@ public:
|
||||
PLUGIN_EXPORT GameList PLUGIN_gameIDList() { return Engine_##ID##_gameIDList(); } \
|
||||
PLUGIN_EXPORT GameDescriptor PLUGIN_findGameID(const char *gameid) { return Engine_##ID##_findGameID(gameid); } \
|
||||
PLUGIN_EXPORT PluginError PLUGIN_createEngine(OSystem *syst, Engine **engine) { return Engine_##ID##_create(syst, engine); } \
|
||||
PLUGIN_EXPORT DetectedGameList PLUGIN_detectGames(const FSList &fslist) { return Engine_##ID##_detectGames(fslist); } \
|
||||
PLUGIN_EXPORT GameList PLUGIN_detectGames(const FSList &fslist) { return Engine_##ID##_detectGames(fslist); } \
|
||||
} \
|
||||
void dummyFuncToAllowTrailingSemicolon()
|
||||
#endif
|
||||
@ -161,7 +132,7 @@ class PluginRegistrator {
|
||||
public:
|
||||
typedef GameDescriptor (*GameIDQueryFunc)(const char *gameid);
|
||||
typedef PluginError (*EngineFactory)(OSystem *syst, Engine **engine);
|
||||
typedef DetectedGameList (*DetectFunc)(const FSList &fslist);
|
||||
typedef GameList (*DetectFunc)(const FSList &fslist);
|
||||
|
||||
protected:
|
||||
const char *_name;
|
||||
@ -225,7 +196,7 @@ public:
|
||||
|
||||
const PluginList &getPlugins() { return _plugins; }
|
||||
|
||||
DetectedGameList detectGames(const FSList &fslist) const;
|
||||
GameList detectGames(const FSList &fslist) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -34,7 +34,7 @@
|
||||
namespace Common {
|
||||
|
||||
PluginError ADVANCED_DETECTOR_ENGINE_CREATE(
|
||||
DetectedGameList (*detectFunc)(const FSList &fslist),
|
||||
GameList (*detectFunc)(const FSList &fslist),
|
||||
const Common::ADObsoleteGameID *obsoleteList
|
||||
) {
|
||||
const char *gameid = ConfMan.get("gameid").c_str();
|
||||
@ -61,10 +61,10 @@ PluginError ADVANCED_DETECTOR_ENGINE_CREATE(
|
||||
return kInvalidPathError;
|
||||
}
|
||||
|
||||
DetectedGameList detectedGames = detectFunc(fslist);
|
||||
GameList detectedGames = detectFunc(fslist);
|
||||
|
||||
for (uint i = 0; i < detectedGames.size(); i++) {
|
||||
if (detectedGames[i].gameid == gameid) {
|
||||
if (detectedGames[i].gameid() == gameid) {
|
||||
return kNoError;
|
||||
}
|
||||
}
|
||||
@ -89,18 +89,18 @@ GameDescriptor ADVANCED_DETECTOR_FIND_GAMEID(
|
||||
const Common::ADObsoleteGameID *o = obsoleteList;
|
||||
while (o->from) {
|
||||
if (0 == scumm_stricmp(gameid, o->from)) {
|
||||
gs.gameid = gameid;
|
||||
gs.description = "Obsolete game ID";
|
||||
gs["gameid"] = gameid;
|
||||
gs["description"] = "Obsolete game ID";
|
||||
return gs;
|
||||
}
|
||||
o++;
|
||||
}
|
||||
} else
|
||||
return *g;
|
||||
return GameDescriptor(g->gameid, g->description);
|
||||
return gs;
|
||||
}
|
||||
|
||||
static DetectedGame toDetectedGame(const ADGameDescription &g, const PlainGameDescriptor *sg) {
|
||||
static GameDescriptor toGameDescriptor(const ADGameDescription &g, const PlainGameDescriptor *sg) {
|
||||
const char *title = 0;
|
||||
|
||||
while (sg->gameid) {
|
||||
@ -109,19 +109,19 @@ static DetectedGame toDetectedGame(const ADGameDescription &g, const PlainGameDe
|
||||
sg++;
|
||||
}
|
||||
|
||||
DetectedGame dg(g.gameid, title, g.language, g.platform);
|
||||
dg.updateDesc(g.extra);
|
||||
return dg;
|
||||
GameDescriptor gd(g.gameid, title, g.language, g.platform);
|
||||
gd.updateDesc(g.extra);
|
||||
return gd;
|
||||
}
|
||||
|
||||
DetectedGameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
|
||||
GameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
|
||||
const FSList &fslist,
|
||||
const byte *descs,
|
||||
const int descItemSize,
|
||||
const int md5Bytes,
|
||||
const PlainGameDescriptor *list
|
||||
) {
|
||||
DetectedGameList detectedGames;
|
||||
GameList detectedGames;
|
||||
Common::AdvancedDetector ad;
|
||||
Common::ADList matches;
|
||||
Common::ADGameDescList descList;
|
||||
@ -137,7 +137,7 @@ DetectedGameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
|
||||
matches = ad.detectGame(&fslist, md5Bytes, Common::UNK_LANG, Common::kPlatformUnknown);
|
||||
|
||||
for (uint i = 0; i < matches.size(); i++)
|
||||
detectedGames.push_back(toDetectedGame(*(const ADGameDescription *)(descs + matches[i] * descItemSize), list));
|
||||
detectedGames.push_back(toGameDescriptor(*(const ADGameDescription *)(descs + matches[i] * descItemSize), list));
|
||||
|
||||
return detectedGames;
|
||||
}
|
||||
@ -150,7 +150,7 @@ int ADVANCED_DETECTOR_DETECT_INIT_GAME(
|
||||
) {
|
||||
int gameNumber = -1;
|
||||
|
||||
DetectedGameList detectedGames;
|
||||
GameList detectedGames;
|
||||
Common::AdvancedDetector ad;
|
||||
Common::ADList matches;
|
||||
Common::ADGameDescList descList;
|
||||
@ -184,7 +184,7 @@ int ADVANCED_DETECTOR_DETECT_INIT_GAME(
|
||||
error("TODO invalid gameNumber %d (max. expected value: %d)", gameNumber, descList.size());
|
||||
}
|
||||
|
||||
debug(2, "Running %s", toDetectedGame(*(const ADGameDescription *)(descs + gameNumber * descItemSize), list).description.c_str());
|
||||
debug(2, "Running %s", toGameDescriptor(*(const ADGameDescription *)(descs + gameNumber * descItemSize), list).description().c_str());
|
||||
|
||||
return gameNumber;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ GameDescriptor ADVANCED_DETECTOR_FIND_GAMEID(
|
||||
|
||||
// FIXME/TODO: Rename this function to something more sensible.
|
||||
// Possibly move it inside class AdvancedDetector ?
|
||||
DetectedGameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
|
||||
GameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
|
||||
const FSList &fslist,
|
||||
const byte *descs,
|
||||
const int descItemSize,
|
||||
@ -123,7 +123,7 @@ int ADVANCED_DETECTOR_DETECT_INIT_GAME(
|
||||
// FIXME/TODO: Rename this function to something more sensible.
|
||||
// Possibly move it inside class AdvancedDetector ?
|
||||
PluginError ADVANCED_DETECTOR_ENGINE_CREATE(
|
||||
DetectedGameList (*detectFunc)(const FSList &fslist),
|
||||
GameList (*detectFunc)(const FSList &fslist),
|
||||
const Common::ADObsoleteGameID *obsoleteList
|
||||
);
|
||||
|
||||
@ -135,7 +135,7 @@ PluginError ADVANCED_DETECTOR_ENGINE_CREATE(
|
||||
GameDescriptor Engine_##engine##_findGameID(const char *gameid) { \
|
||||
return Common::ADVANCED_DETECTOR_FIND_GAMEID(gameid,list,obsoleteList); \
|
||||
} \
|
||||
DetectedGameList Engine_##engine##_detectGames(const FSList &fslist) { \
|
||||
GameList Engine_##engine##_detectGames(const FSList &fslist) { \
|
||||
return detectFunc(fslist); \
|
||||
} \
|
||||
PluginError Engine_##engine##_create(OSystem *syst, Engine **engine) { \
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
|
||||
namespace Agi {
|
||||
static DetectedGameList GAME_detectGames(const FSList &fslist);
|
||||
static GameList GAME_detectGames(const FSList &fslist);
|
||||
}
|
||||
|
||||
static const PlainGameDescriptor agiGames[] = {
|
||||
@ -958,7 +958,7 @@ bool AgiEngine::initGame() {
|
||||
return true;
|
||||
}
|
||||
|
||||
DetectedGameList GAME_detectGames(const FSList &fslist) {
|
||||
GameList GAME_detectGames(const FSList &fslist) {
|
||||
return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
|
||||
fslist,
|
||||
(const byte *)gameDescriptions,
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "agos/agos.h"
|
||||
|
||||
namespace AGOS {
|
||||
static DetectedGameList GAME_detectGames(const FSList &fslist);
|
||||
static GameList GAME_detectGames(const FSList &fslist);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,7 +88,7 @@ bool AGOSEngine::initGame() {
|
||||
return true;
|
||||
}
|
||||
|
||||
DetectedGameList GAME_detectGames(const FSList &fslist) {
|
||||
GameList GAME_detectGames(const FSList &fslist) {
|
||||
return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
|
||||
fslist,
|
||||
(const byte *)gameDescriptions,
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "cine/cine.h"
|
||||
|
||||
namespace Cine {
|
||||
static DetectedGameList GAME_detectGames(const FSList &fslist);
|
||||
static GameList GAME_detectGames(const FSList &fslist);
|
||||
}
|
||||
|
||||
static const PlainGameDescriptor cineGames[] = {
|
||||
@ -433,7 +433,7 @@ bool CineEngine::initGame() {
|
||||
return true;
|
||||
}
|
||||
|
||||
DetectedGameList GAME_detectGames(const FSList &fslist) {
|
||||
GameList GAME_detectGames(const FSList &fslist) {
|
||||
return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
|
||||
fslist,
|
||||
(const byte *)gameDescriptions,
|
||||
|
@ -813,11 +813,11 @@ GameDescriptor Engine_GOB_findGameID(const char *gameid) {
|
||||
break;
|
||||
g++;
|
||||
}
|
||||
return *g;
|
||||
return GameDescriptor(g->gameid, g->description);
|
||||
}
|
||||
|
||||
DetectedGameList Engine_GOB_detectGames(const FSList &fslist) {
|
||||
DetectedGameList detectedGames;
|
||||
GameList Engine_GOB_detectGames(const FSList &fslist) {
|
||||
GameList detectedGames;
|
||||
const GameSettings *g;
|
||||
FSList::const_iterator file;
|
||||
|
||||
@ -843,7 +843,7 @@ DetectedGameList Engine_GOB_detectGames(const FSList &fslist) {
|
||||
}
|
||||
for (g = gob_games; g->gameid; g++) {
|
||||
if (strcmp(g->md5sum, (char *)md5str) == 0) {
|
||||
detectedGames.push_back(DetectedGame(g->gameid, g->description));
|
||||
detectedGames.push_back(GameDescriptor(g->gameid, g->description));
|
||||
}
|
||||
}
|
||||
if (detectedGames.empty()) {
|
||||
|
@ -140,7 +140,7 @@ GameDescriptor Engine_KYRA_findGameID(const char *gameid) {
|
||||
return Common::ADVANCED_DETECTOR_FIND_GAMEID(gameid, gameList, 0);
|
||||
}
|
||||
|
||||
DetectedGameList Engine_KYRA_detectGames(const FSList &fslist) {
|
||||
GameList Engine_KYRA_detectGames(const FSList &fslist) {
|
||||
return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
|
||||
fslist,
|
||||
(const byte *)adGameDescs,
|
||||
|
@ -103,11 +103,11 @@ GameDescriptor Engine_LURE_findGameID(const char *gameid) {
|
||||
break;
|
||||
g++;
|
||||
}
|
||||
return *g;
|
||||
return GameDescriptor(g->gameid, g->description);
|
||||
}
|
||||
|
||||
DetectedGameList Engine_LURE_detectGames(const FSList &fslist) {
|
||||
DetectedGameList detectedGames;
|
||||
GameList Engine_LURE_detectGames(const FSList &fslist) {
|
||||
GameList detectedGames;
|
||||
const GameSettings *g;
|
||||
FSList::const_iterator file;
|
||||
|
||||
@ -137,7 +137,7 @@ DetectedGameList Engine_LURE_detectGames(const FSList &fslist) {
|
||||
}
|
||||
for (g = lure_games; g->gameid; g++) {
|
||||
if (strcmp(g->md5sum, (char *)md5str) == 0) {
|
||||
DetectedGame dg(*g, g->language);
|
||||
GameDescriptor dg(g->gameid, g->description, g->language);
|
||||
dg.updateDesc((g->features & GF_FLOPPY) ? "Floppy" : 0);
|
||||
detectedGames.push_back(dg);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "parallaction/parallaction.h"
|
||||
|
||||
namespace Parallaction {
|
||||
static DetectedGameList GAME_detectGames(const FSList &fslist);
|
||||
static GameList GAME_detectGames(const FSList &fslist);
|
||||
}
|
||||
|
||||
static const PlainGameDescriptor parallactionGames[] = {
|
||||
@ -84,7 +84,7 @@ bool Parallaction::detectGame() {
|
||||
return true;
|
||||
}
|
||||
|
||||
DetectedGameList GAME_detectGames(const FSList &fslist) {
|
||||
GameList GAME_detectGames(const FSList &fslist) {
|
||||
return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
|
||||
fslist,
|
||||
(const byte *)gameDescriptions,
|
||||
|
@ -65,8 +65,8 @@ GameDescriptor Engine_QUEEN_findGameID(const char *gameid) {
|
||||
return GameDescriptor();
|
||||
}
|
||||
|
||||
DetectedGameList Engine_QUEEN_detectGames(const FSList &fslist) {
|
||||
DetectedGameList detectedGames;
|
||||
GameList Engine_QUEEN_detectGames(const FSList &fslist) {
|
||||
GameList detectedGames;
|
||||
|
||||
// Iterate over all files in the given directory
|
||||
for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
|
||||
@ -80,7 +80,7 @@ DetectedGameList Engine_QUEEN_detectGames(const FSList &fslist) {
|
||||
}
|
||||
Queen::DetectedGameVersion version;
|
||||
if (Queen::Resource::detectVersion(&version, &dataFile)) {
|
||||
DetectedGame dg(queenGameDescriptor, version.language, Common::kPlatformPC);
|
||||
GameDescriptor dg(queenGameDescriptor.gameid, queenGameDescriptor.description, version.language, Common::kPlatformPC);
|
||||
if (version.features & Queen::GF_DEMO) {
|
||||
dg.updateDesc("Demo");
|
||||
} else if (version.features & Queen::GF_INTERVIEW) {
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
|
||||
namespace Saga {
|
||||
static DetectedGameList GAME_detectGames(const FSList &fslist);
|
||||
static GameList GAME_detectGames(const FSList &fslist);
|
||||
}
|
||||
|
||||
static const PlainGameDescriptor saga_games[] = {
|
||||
@ -73,7 +73,7 @@ bool SagaEngine::initGame() {
|
||||
return _resource->createContexts();
|
||||
}
|
||||
|
||||
DetectedGameList GAME_detectGames(const FSList &fslist) {
|
||||
GameList GAME_detectGames(const FSList &fslist) {
|
||||
return Common::ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
|
||||
fslist,
|
||||
(const byte *)gameDescriptions,
|
||||
|
@ -1360,8 +1360,8 @@ GameDescriptor Engine_SCUMM_findGameID(const char *gameid) {
|
||||
const ObsoleteGameID *o = obsoleteGameIDsTable;
|
||||
while (o->from) {
|
||||
if (0 == scumm_stricmp(gameid, o->from)) {
|
||||
gs.gameid = gameid;
|
||||
gs.description = "Obsolete game ID";
|
||||
gs["gameid"] = gameid;
|
||||
gs["description"] = "Obsolete game ID";
|
||||
return gs;
|
||||
}
|
||||
o++;
|
||||
@ -1370,15 +1370,15 @@ GameDescriptor Engine_SCUMM_findGameID(const char *gameid) {
|
||||
}
|
||||
|
||||
|
||||
DetectedGameList Engine_SCUMM_detectGames(const FSList &fslist) {
|
||||
DetectedGameList detectedGames;
|
||||
GameList Engine_SCUMM_detectGames(const FSList &fslist) {
|
||||
GameList detectedGames;
|
||||
Common::List<DetectorResult> results;
|
||||
|
||||
detectGames(fslist, results, 0);
|
||||
|
||||
|
||||
for (Common::List<DetectorResult>::iterator x = results.begin(); x != results.end(); ++x) {
|
||||
DetectedGame dg(x->game.gameid, findDescriptionFromGameID(x->game.gameid),
|
||||
GameDescriptor dg(x->game.gameid, findDescriptionFromGameID(x->game.gameid),
|
||||
x->language, x->game.platform);
|
||||
dg.updateDesc(x->extra); // Append additional information, if set, to the description.
|
||||
detectedGames.push_back(dg);
|
||||
|
@ -110,8 +110,8 @@ static const SkyVersion skyVersions[] = {
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
DetectedGameList Engine_SKY_detectGames(const FSList &fslist) {
|
||||
DetectedGameList detectedGames;
|
||||
GameList Engine_SKY_detectGames(const FSList &fslist) {
|
||||
GameList detectedGames;
|
||||
bool hasSkyDsk = false;
|
||||
bool hasSkyDnr = false;
|
||||
int dinnerTableEntries = -1;
|
||||
@ -144,7 +144,7 @@ DetectedGameList Engine_SKY_detectGames(const FSList &fslist) {
|
||||
// Match found, add to list of candidates, then abort inner loop.
|
||||
// The game detector uses US English by default. We want British
|
||||
// English to match the recorded voices better.
|
||||
DetectedGame dg(skySetting, Common::UNK_LANG, Common::kPlatformUnknown);
|
||||
GameDescriptor dg(skySetting.gameid, skySetting.description, Common::UNK_LANG, Common::kPlatformUnknown);
|
||||
const SkyVersion *sv = skyVersions;
|
||||
while (sv->dinnerTableEntries) {
|
||||
if (dinnerTableEntries == sv->dinnerTableEntries &&
|
||||
|
@ -118,9 +118,9 @@ void Sword1CheckDirectory(const FSList &fslist, bool *filesFound) {
|
||||
}
|
||||
}
|
||||
|
||||
DetectedGameList Engine_SWORD1_detectGames(const FSList &fslist) {
|
||||
GameList Engine_SWORD1_detectGames(const FSList &fslist) {
|
||||
int i, j;
|
||||
DetectedGameList detectedGames;
|
||||
GameList detectedGames;
|
||||
bool filesFound[NUM_FILES_TO_CHECK];
|
||||
for (i = 0; i < NUM_FILES_TO_CHECK; i++)
|
||||
filesFound[i] = false;
|
||||
|
@ -65,7 +65,7 @@ GameList Engine_SWORD2_gameIDList() {
|
||||
const Sword2::GameSettings *g = Sword2::sword2_settings;
|
||||
GameList games;
|
||||
while (g->gameid) {
|
||||
games.push_back(*g);
|
||||
games.push_back(GameDescriptor(g->gameid, g->description));
|
||||
g++;
|
||||
}
|
||||
return games;
|
||||
@ -78,11 +78,11 @@ GameDescriptor Engine_SWORD2_findGameID(const char *gameid) {
|
||||
break;
|
||||
g++;
|
||||
}
|
||||
return *g;
|
||||
return GameDescriptor(g->gameid, g->description);
|
||||
}
|
||||
|
||||
DetectedGameList Engine_SWORD2_detectGames(const FSList &fslist) {
|
||||
DetectedGameList detectedGames;
|
||||
GameList Engine_SWORD2_detectGames(const FSList &fslist) {
|
||||
GameList detectedGames;
|
||||
const Sword2::GameSettings *g;
|
||||
|
||||
// TODO: It would be nice if we had code here which distinguishes
|
||||
@ -97,7 +97,7 @@ DetectedGameList Engine_SWORD2_detectGames(const FSList &fslist) {
|
||||
|
||||
if (0 == scumm_stricmp(g->detectname, fileName)) {
|
||||
// Match found, add to list of candidates, then abort inner loop.
|
||||
detectedGames.push_back(*g);
|
||||
detectedGames.push_back(GameDescriptor(g->gameid, g->description));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -118,10 +118,10 @@ PluginError Engine_SWORD2_create(OSystem *syst, Engine **engine) {
|
||||
|
||||
// Invoke the detector
|
||||
Common::String gameid = ConfMan.get("gameid");
|
||||
DetectedGameList detectedGames = Engine_SWORD2_detectGames(fslist);
|
||||
GameList detectedGames = Engine_SWORD2_detectGames(fslist);
|
||||
|
||||
for (uint i = 0; i < detectedGames.size(); i++) {
|
||||
if (detectedGames[i].gameid == gameid) {
|
||||
if (detectedGames[i].gameid() == gameid) {
|
||||
*engine = new Sword2::Sword2Engine(syst);
|
||||
return kNoError;
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ GameDescriptor Engine_TOUCHE_findGameID(const char *gameid) {
|
||||
return GameDescriptor();
|
||||
}
|
||||
|
||||
DetectedGameList Engine_TOUCHE_detectGames(const FSList &fslist) {
|
||||
GameList Engine_TOUCHE_detectGames(const FSList &fslist) {
|
||||
bool foundFile = false;
|
||||
FSList::const_iterator file;
|
||||
for (file = fslist.begin(); file != fslist.end(); ++file) {
|
||||
@ -140,7 +140,7 @@ DetectedGameList Engine_TOUCHE_detectGames(const FSList &fslist) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
DetectedGameList detectedGames;
|
||||
GameList detectedGames;
|
||||
if (foundFile) {
|
||||
// Currently, the detection code is based on a MD5 checksum. If all known versions
|
||||
// have a different file size for TOUCHE.DAT, we may consider using this to do the
|
||||
@ -150,7 +150,7 @@ DetectedGameList Engine_TOUCHE_detectGames(const FSList &fslist) {
|
||||
for (int i = 0; i < ARRAYSIZE(toucheGameVersionsTable); ++i) {
|
||||
const GameVersion *gv = &toucheGameVersionsTable[i];
|
||||
if (md5digest.equalsIgnoreCase(gv->md5digest)) {
|
||||
DetectedGame dg(toucheGameDescriptor.gameid, gv->description, gv->language, gv->platform);
|
||||
GameDescriptor dg(toucheGameDescriptor.gameid, gv->description, gv->language, gv->platform);
|
||||
detectedGames.push_back(dg);
|
||||
break;
|
||||
}
|
||||
@ -172,12 +172,12 @@ PluginError Engine_TOUCHE_create(OSystem *system, Engine **engine) {
|
||||
if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
|
||||
return kInvalidPathError;
|
||||
}
|
||||
DetectedGameList game = Engine_TOUCHE_detectGames(fslist);
|
||||
GameList game = Engine_TOUCHE_detectGames(fslist);
|
||||
if (game.size() != 1) {
|
||||
return kNoGameDataFoundError;
|
||||
}
|
||||
assert(engine);
|
||||
*engine = new Touche::ToucheEngine(system, game[0].language);
|
||||
*engine = new Touche::ToucheEngine(system, game[0].language());
|
||||
return kNoError;
|
||||
}
|
||||
|
||||
|
@ -573,8 +573,8 @@ void LauncherDialog::updateListing() {
|
||||
gameid = iter->_key;
|
||||
if (description.empty()) {
|
||||
GameDescriptor g = Base::findGame(gameid);
|
||||
if (!g.description.empty())
|
||||
description = g.description;
|
||||
if (g.contains("description"))
|
||||
description = g.description();
|
||||
}
|
||||
|
||||
if (!gameid.empty() && !description.empty()) {
|
||||
@ -606,14 +606,14 @@ void LauncherDialog::addGameRecursive(FilesystemNode dir) {
|
||||
}
|
||||
|
||||
// Run the detector on the dir
|
||||
DetectedGameList candidates(PluginManager::instance().detectGames(files));
|
||||
GameList candidates(PluginManager::instance().detectGames(files));
|
||||
|
||||
if (candidates.size() >= 1) {
|
||||
// At least one match was found. For now we just take the first one...
|
||||
// a more sophisticated solution would do something more clever here,
|
||||
// e.g. ask the user which one to pick (make sure to display the
|
||||
// path, too).
|
||||
DetectedGame result = candidates[0];
|
||||
GameDescriptor result = candidates[0];
|
||||
addGameToConf(dir, result, true);
|
||||
}
|
||||
|
||||
@ -661,7 +661,7 @@ void LauncherDialog::addGame() {
|
||||
|
||||
// ...so let's determine a list of candidates, games that
|
||||
// could be contained in the specified directory.
|
||||
DetectedGameList candidates(PluginManager::instance().detectGames(files));
|
||||
GameList candidates(PluginManager::instance().detectGames(files));
|
||||
|
||||
int idx;
|
||||
if (candidates.empty()) {
|
||||
@ -676,32 +676,32 @@ void LauncherDialog::addGame() {
|
||||
// Display the candidates to the user and let her/him pick one
|
||||
StringList list;
|
||||
for (idx = 0; idx < (int)candidates.size(); idx++)
|
||||
list.push_back(candidates[idx].description);
|
||||
list.push_back(candidates[idx].description());
|
||||
|
||||
ChooserDialog dialog("Pick the game:");
|
||||
dialog.setList(list);
|
||||
idx = dialog.runModal();
|
||||
}
|
||||
if (0 <= idx && idx < (int)candidates.size()) {
|
||||
DetectedGame result = candidates[idx];
|
||||
GameDescriptor result = candidates[idx];
|
||||
addGameToConf(dir, result, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LauncherDialog::addGameToConf(FilesystemNode dir, DetectedGame result, bool suppressEditDialog) {
|
||||
void LauncherDialog::addGameToConf(FilesystemNode dir, GameDescriptor result, bool suppressEditDialog) {
|
||||
// The auto detector or the user made a choice.
|
||||
// Pick a domain name which does not yet exist (after all, we
|
||||
// are *adding* a game to the config, not replacing).
|
||||
String domain(result.gameid);
|
||||
String domain(result.gameid());
|
||||
if (ConfMan.hasGameDomain(domain)) {
|
||||
int suffixN = 1;
|
||||
char suffix[16];
|
||||
|
||||
while (ConfMan.hasGameDomain(domain)) {
|
||||
snprintf(suffix, 16, "-%d", suffixN);
|
||||
domain = result.gameid + suffix;
|
||||
domain = result.gameid() + suffix;
|
||||
suffixN++;
|
||||
}
|
||||
}
|
||||
@ -718,23 +718,23 @@ void LauncherDialog::addGameToConf(FilesystemNode dir, DetectedGame result, bool
|
||||
// game target, we can change this (currently, you can only query
|
||||
// for the generic gameid description; it's not possible to obtain
|
||||
// a description which contains extended information like language, etc.).
|
||||
ConfMan.set("description", result.description, domain);
|
||||
ConfMan.set("description", result.description(), domain);
|
||||
|
||||
ConfMan.set("gameid", result.gameid, domain);
|
||||
ConfMan.set("gameid", result.gameid(), domain);
|
||||
ConfMan.set("path", dir.path(), domain);
|
||||
|
||||
// Set language if specified
|
||||
if (result.language != Common::UNK_LANG)
|
||||
ConfMan.set("language", Common::getLanguageCode(result.language), domain);
|
||||
if (result.language() != Common::UNK_LANG)
|
||||
ConfMan.set("language", Common::getLanguageCode(result.language()), domain);
|
||||
|
||||
// Set platform if specified
|
||||
if (result.platform != Common::kPlatformUnknown)
|
||||
ConfMan.set("platform", Common::getPlatformCode(result.platform), domain);
|
||||
if (result.platform() != Common::kPlatformUnknown)
|
||||
ConfMan.set("platform", Common::getPlatformCode(result.platform()), domain);
|
||||
|
||||
// Display edit dialog for the new entry
|
||||
bool saveit = true;
|
||||
if (!suppressEditDialog) {
|
||||
EditGameDialog editDialog(domain, result.description);
|
||||
EditGameDialog editDialog(domain, result.description());
|
||||
saveit = (editDialog.runModal() > 0);
|
||||
}
|
||||
if (saveit) {
|
||||
@ -781,7 +781,7 @@ void LauncherDialog::editGame(int item) {
|
||||
String gameId(ConfMan.get("gameid", _domains[item]));
|
||||
if (gameId.empty())
|
||||
gameId = _domains[item];
|
||||
EditGameDialog editDialog(_domains[item], Base::findGame(gameId).description);
|
||||
EditGameDialog editDialog(_domains[item], Base::findGame(gameId).description());
|
||||
if (editDialog.runModal() > 0) {
|
||||
// User pressed OK, so make changes permanent
|
||||
|
||||
|
@ -68,7 +68,7 @@ protected:
|
||||
|
||||
void selectGame(const String &name);
|
||||
|
||||
void addGameToConf(FilesystemNode dir, DetectedGame result, bool suppressEditDialog);
|
||||
void addGameToConf(FilesystemNode dir, GameDescriptor result, bool suppressEditDialog);
|
||||
void addGameRecursive(FilesystemNode dir);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user