ENGINES: Allow engines to decide if unknown variants can be run

This commit is contained in:
Thierry Crozat 2021-04-19 22:28:47 +01:00
parent e3d254d963
commit 0622c9f8fb
2 changed files with 9 additions and 4 deletions

View File

@ -241,8 +241,7 @@ DetectedGames AdvancedMetaEngineDetection::detectGames(const Common::FSList &fsl
for (uint i = 0; i < matches.size(); i++) {
DetectedGame game = toDetectedGame(matches[i]);
if (game.hasUnknownFiles) {
// Non fallback games with unknown files cannot be added/launched
if (game.hasUnknownFiles && !canPlayUnknownVariants()) {
game.canBeAdded = false;
}
@ -251,7 +250,7 @@ DetectedGames AdvancedMetaEngineDetection::detectGames(const Common::FSList &fsl
bool foundKnownGames = false;
for (uint i = 0; i < detectedGames.size(); i++) {
foundKnownGames |= detectedGames[i].canBeAdded;
foundKnownGames |= !detectedGames[i].hasUnknownFiles;
}
if (!foundKnownGames) {
@ -344,7 +343,7 @@ Common::Error AdvancedMetaEngineDetection::createInstance(OSystem *syst, Engine
ADDetectedGame agdDesc;
for (uint i = 0; i < matches.size(); i++) {
if (matches[i].desc->gameId == gameid && !matches[i].hasUnknownFiles) {
if (matches[i].desc->gameId == gameid && (!matches[i].hasUnknownFiles || canPlayUnknownVariants())) {
agdDesc = matches[i];
break;
}

View File

@ -402,6 +402,12 @@ protected:
*/
virtual ADDetectedGames detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra) const;
/**
* @return True if variant of a game with unknown files can be played with the engine and false otherwise.
* By default this is false.
*/
virtual bool canPlayUnknownVariants() const { return false; }
/**
* Iterate over all @ref ADFileBasedFallback records inside @p fileBasedFallback
* and return the record (or rather, the ADGameDescription