ENGINES: Cleanup DetectedGame initialization in the AD
This commit is contained in:
parent
90b78c5446
commit
2fe060e5c9
3 changed files with 44 additions and 60 deletions
|
@ -33,33 +33,16 @@
|
||||||
#include "engines/advancedDetector.h"
|
#include "engines/advancedDetector.h"
|
||||||
#include "engines/obsolete.h"
|
#include "engines/obsolete.h"
|
||||||
|
|
||||||
DetectedGame AdvancedMetaEngine::toDetectedGame(const ADDetectedGame &adGame) const {
|
static Common::String sanitizeName(const char *name) {
|
||||||
const char *title;
|
Common::String res;
|
||||||
const char *extra;
|
|
||||||
|
|
||||||
if (adGame.desc->flags & ADGF_USEEXTRAASTITLE) {
|
while (*name) {
|
||||||
title = adGame.desc->extra;
|
if (Common::isAlnum(*name))
|
||||||
extra = "";
|
res += tolower(*name);
|
||||||
} else {
|
name++;
|
||||||
const PlainGameDescriptor *pgd = findPlainGameDescriptor(adGame.desc->gameId, _gameIds);
|
|
||||||
title = pgd->description;
|
|
||||||
extra = adGame.desc->extra;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DetectedGame game(adGame.desc->gameId, title, adGame.desc->language, adGame.desc->platform, extra);
|
return res;
|
||||||
game.engineName = getName();
|
|
||||||
game.hasUnknownFiles = adGame.hasUnknownFiles;
|
|
||||||
game.matchedFiles = adGame.matchedFiles;
|
|
||||||
|
|
||||||
game.gameSupportLevel = kStableGame;
|
|
||||||
if (adGame.desc->flags & ADGF_UNSTABLE)
|
|
||||||
game.gameSupportLevel = kUnstableGame;
|
|
||||||
else if (adGame.desc->flags & ADGF_TESTING)
|
|
||||||
game.gameSupportLevel = kTestingGame;
|
|
||||||
|
|
||||||
updateGameDescriptor(game, adGame.desc);
|
|
||||||
|
|
||||||
return game;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,8 +51,14 @@ DetectedGame AdvancedMetaEngine::toDetectedGame(const ADDetectedGame &adGame) co
|
||||||
* or (if ADGF_DEMO has been set)
|
* or (if ADGF_DEMO has been set)
|
||||||
* GAMEID-demo-PLAFORM-LANG
|
* GAMEID-demo-PLAFORM-LANG
|
||||||
*/
|
*/
|
||||||
static Common::String generatePreferredTarget(const Common::String &id, const ADGameDescription *desc) {
|
static Common::String generatePreferredTarget(const ADGameDescription *desc) {
|
||||||
Common::String res(id);
|
Common::String res;
|
||||||
|
|
||||||
|
if (desc->flags & ADGF_AUTOGENTARGET && desc->extra && *desc->extra) {
|
||||||
|
res = sanitizeName(desc->extra);
|
||||||
|
} else {
|
||||||
|
res = desc->gameId;
|
||||||
|
}
|
||||||
|
|
||||||
if (desc->flags & ADGF_DEMO) {
|
if (desc->flags & ADGF_DEMO) {
|
||||||
res = res + "-demo";
|
res = res + "-demo";
|
||||||
|
@ -90,42 +79,43 @@ static Common::String generatePreferredTarget(const Common::String &id, const AD
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Common::String sanitizeName(const char *name) {
|
DetectedGame AdvancedMetaEngine::toDetectedGame(const ADDetectedGame &adGame) const {
|
||||||
Common::String res;
|
const ADGameDescription *desc = adGame.desc;
|
||||||
|
|
||||||
while (*name) {
|
const char *gameId = _singleId ? _singleId : desc->gameId;
|
||||||
if (Common::isAlnum(*name))
|
|
||||||
res += tolower(*name);
|
const char *title;
|
||||||
name++;
|
const char *extra;
|
||||||
|
if (desc->flags & ADGF_USEEXTRAASTITLE) {
|
||||||
|
title = desc->extra;
|
||||||
|
extra = "";
|
||||||
|
} else {
|
||||||
|
const PlainGameDescriptor *pgd = findPlainGameDescriptor(desc->gameId, _gameIds);
|
||||||
|
title = pgd->description;
|
||||||
|
extra = desc->extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
DetectedGame game(gameId, title, desc->language, desc->platform, extra);
|
||||||
}
|
game.hasUnknownFiles = adGame.hasUnknownFiles;
|
||||||
|
game.matchedFiles = adGame.matchedFiles;
|
||||||
|
game.preferredTarget = generatePreferredTarget(desc);
|
||||||
|
|
||||||
void AdvancedMetaEngine::updateGameDescriptor(DetectedGame &desc, const ADGameDescription *realDesc) const {
|
game.gameSupportLevel = kStableGame;
|
||||||
if (_singleId) {
|
if (desc->flags & ADGF_UNSTABLE)
|
||||||
desc.preferredTarget = desc.gameId;
|
game.gameSupportLevel = kUnstableGame;
|
||||||
desc.gameId = _singleId;
|
else if (desc->flags & ADGF_TESTING)
|
||||||
}
|
game.gameSupportLevel = kTestingGame;
|
||||||
|
|
||||||
if (desc.preferredTarget.empty())
|
game.setGUIOptions(desc->guiOptions + _guiOptions);
|
||||||
desc.preferredTarget = desc.gameId;
|
game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(desc->language));
|
||||||
|
|
||||||
if (realDesc->flags & ADGF_AUTOGENTARGET) {
|
if (desc->flags & ADGF_ADDENGLISH)
|
||||||
if (*realDesc->extra)
|
game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::EN_ANY));
|
||||||
desc.preferredTarget = sanitizeName(realDesc->extra);
|
|
||||||
}
|
|
||||||
|
|
||||||
desc.preferredTarget = generatePreferredTarget(desc.preferredTarget, realDesc);
|
|
||||||
|
|
||||||
if (_flags & kADFlagUseExtraAsHint)
|
if (_flags & kADFlagUseExtraAsHint)
|
||||||
desc.extra = realDesc->extra;
|
game.extra = desc->extra;
|
||||||
|
|
||||||
desc.setGUIOptions(realDesc->guiOptions + _guiOptions);
|
return game;
|
||||||
desc.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(realDesc->language));
|
|
||||||
|
|
||||||
if (realDesc->flags & ADGF_ADDENGLISH)
|
|
||||||
desc.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::EN_ANY));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cleanupPirated(ADDetectedGames &matched) {
|
bool cleanupPirated(ADDetectedGames &matched) {
|
||||||
|
|
|
@ -320,9 +320,6 @@ protected:
|
||||||
*/
|
*/
|
||||||
ADDetectedGame detectGameFilebased(const FileMap &allFiles, const Common::FSList &fslist, const ADFileBasedFallback *fileBasedFallback) const;
|
ADDetectedGame detectGameFilebased(const FileMap &allFiles, const Common::FSList &fslist, const ADFileBasedFallback *fileBasedFallback) const;
|
||||||
|
|
||||||
// TODO
|
|
||||||
void updateGameDescriptor(DetectedGame &desc, const ADGameDescription *realDesc) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compose a hashmap of all files in fslist.
|
* Compose a hashmap of all files in fslist.
|
||||||
* Includes nifty stuff like removing trailing dots and ignoring case.
|
* Includes nifty stuff like removing trailing dots and ignoring case.
|
||||||
|
|
|
@ -75,10 +75,7 @@ DetectedGame::DetectedGame(const Common::String &id, const Common::String &d, Co
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectedGame::setGUIOptions(const Common::String &guioptions) {
|
void DetectedGame::setGUIOptions(const Common::String &guioptions) {
|
||||||
if (guioptions.empty())
|
_guiOptions = Common::getGameGUIOptionsDescription(guioptions);
|
||||||
_guiOptions.clear();
|
|
||||||
else
|
|
||||||
_guiOptions = Common::getGameGUIOptionsDescription(guioptions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetectedGame::appendGUIOptions(const Common::String &str) {
|
void DetectedGame::appendGUIOptions(const Common::String &str) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue