ENGINES: Implement per-game options caching in AdvancedDetector via GUIO flags.

This commit is contained in:
Johannes Schickel 2012-02-29 16:48:25 +01:00
parent c84cd8dee8
commit 82ab3056fa
4 changed files with 66 additions and 3 deletions

View File

@ -64,6 +64,14 @@ const struct GameOpt {
{ GUIO_RENDERPC9821, "pc9821" },
{ GUIO_RENDERPC9801, "pc9801" },
{ GUIO_GAMEOPTIONS1, "gameOption1" },
{ GUIO_GAMEOPTIONS2, "gameOption2" },
{ GUIO_GAMEOPTIONS3, "gameOption3" },
{ GUIO_GAMEOPTIONS4, "gameOption4" },
{ GUIO_GAMEOPTIONS5, "gameOption5" },
{ GUIO_GAMEOPTIONS6, "gameOption6" },
{ GUIO_GAMEOPTIONS7, "gameOption7" },
{ GUIO_NONE, 0 }
};

View File

@ -56,6 +56,16 @@
#define GUIO_RENDERPC9821 "\037"
#define GUIO_RENDERPC9801 "\040"
// Special GUIO flags for the AdvancedDetector's caching of game specific
// options.
#define GUIO_GAMEOPTIONS1 "\041"
#define GUIO_GAMEOPTIONS2 "\042"
#define GUIO_GAMEOPTIONS3 "\043"
#define GUIO_GAMEOPTIONS4 "\044"
#define GUIO_GAMEOPTIONS5 "\045"
#define GUIO_GAMEOPTIONS6 "\046"
#define GUIO_GAMEOPTIONS7 "\047"
#define GUIO0() (GUIO_NONE)
#define GUIO1(a) (a)
#define GUIO2(a,b) (a b)

View File

@ -167,6 +167,25 @@ GameList AdvancedMetaEngine::detectGames(const Common::FSList &fslist) const {
return detectedGames;
}
const ExtraGuiOptions AdvancedMetaEngine::getExtraGuiOptions(const Common::String &target) const {
if (!_extraGuiOptions)
return ExtraGuiOptions();
// Query the GUI options
const Common::String guiOptionsString = ConfMan.get("guioptions", target);
const Common::String guiOptions = parseGameGUIOptions(guiOptionsString);
ExtraGuiOptions options;
// Add all the applying extra GUI options.
for (const ADExtraGuiOptionsMap *entry = _extraGuiOptions; entry->guioFlag; ++entry) {
if (guiOptions.contains(entry->guioFlag))
options.push_back(entry->option);
}
return options;
}
Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine) const {
assert(engine);
@ -562,8 +581,9 @@ GameDescriptor AdvancedMetaEngine::findGame(const char *gameid) const {
return GameDescriptor();
}
AdvancedMetaEngine::AdvancedMetaEngine(const void *descs, uint descItemSize, const PlainGameDescriptor *gameids)
: _gameDescriptors((const byte *)descs), _descItemSize(descItemSize), _gameids(gameids) {
AdvancedMetaEngine::AdvancedMetaEngine(const void *descs, uint descItemSize, const PlainGameDescriptor *gameids, const ADExtraGuiOptionsMap *extraGuiOptions)
: _gameDescriptors((const byte *)descs), _descItemSize(descItemSize), _gameids(gameids),
_extraGuiOptions(extraGuiOptions) {
_md5Bytes = 5000;
_singleid = NULL;

View File

@ -133,6 +133,24 @@ enum ADFlags {
};
/**
* Map entry for mapping GUIO_GAMEOPTIONS* to their ExtraGuiOption
* description.
*/
struct ADExtraGuiOptionsMap {
/**
* GUIO_GAMEOPTION* string.
*/
const char *guioFlag;
/**
* The associated option.
*/
ExtraGuiOption option;
};
#define AD_EXTRA_GUI_OPTIONS_TERMINATOR { 0, { 0, 0, 0, 0 } }
/**
* A MetaEngine implementation based around the advanced detector code.
*/
@ -158,6 +176,11 @@ protected:
*/
const PlainGameDescriptor *_gameids;
/**
* A map containing all the extra game GUI options the engine supports.
*/
const ADExtraGuiOptionsMap * const _extraGuiOptions;
/**
* The number of bytes to compute MD5 sum for. The AdvancedDetector
* is primarily based on computing and matching MD5 checksums of files.
@ -211,7 +234,7 @@ protected:
const char * const *_directoryGlobs;
public:
AdvancedMetaEngine(const void *descs, uint descItemSize, const PlainGameDescriptor *gameids);
AdvancedMetaEngine(const void *descs, uint descItemSize, const PlainGameDescriptor *gameids, const ADExtraGuiOptionsMap *extraGuiOptions = 0);
/**
* Returns list of targets supported by the engine.
@ -225,6 +248,8 @@ public:
virtual Common::Error createInstance(OSystem *syst, Engine **engine) const;
virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const;
protected:
// To be implemented by subclasses
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const = 0;