Added new method DetectedGame::updateDesc, to ease generation of uniform description strings

svn-id: r21166
This commit is contained in:
Max Horn 2006-03-09 12:52:10 +00:00
parent cd732d680b
commit 46ee5c8f26
3 changed files with 39 additions and 28 deletions

View File

@ -69,6 +69,37 @@ PluginRegistrator::PluginRegistrator(const char *name, GameList games, GameIDQue
#endif
#pragma mark -
void DetectedGame::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 hasExtraDesc = (extra && extra[0]);
// Adapt the description string if custom platform/language is set.
if (hasCustomLanguage || hasCustomPlatform || hasExtraDesc) {
description += " (";
if (hasCustomLanguage)
description += Common::getLanguageDescription(language);
if (hasCustomPlatform) {
if (hasCustomLanguage)
description += "/";
description += Common::getPlatformDescription(platform);
}
if (hasExtraDesc) {
if (hasCustomPlatform || hasCustomLanguage)
description += "/";
description += extra;
}
description += ")";
}
}
#pragma mark -
#ifndef DYNAMIC_MODULES

View File

@ -54,6 +54,11 @@ struct DetectedGame : public GameDescriptor {
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);
};

View File

@ -1150,12 +1150,8 @@ DetectedGameList Engine_SCUMM_detectGames(const FSList &fslist) {
fileSet[file->path()] = false;
}
// If known, add the platform to the description string
if (dg.platform != Common::kPlatformUnknown) {
dg.description += "(";
dg.description += Common::getPlatformDescription(dg.platform);
dg.description += ")";
}
dg.updateDesc(); // Append the platform, if set, to the description.
detectedGames.push_back(dg);
break;
}
@ -1200,28 +1196,7 @@ DetectedGameList Engine_SCUMM_detectGames(const FSList &fslist) {
dg.platform = Common::kPlatformMacintosh;
else
dg.platform = elem->platform;
const bool hasCustomLanguage = (dg.language != Common::UNK_LANG);
const bool hasCustomPlatform = (dg.platform != Common::kPlatformUnknown);
const bool hasExtraDesc = (elem->extra && elem->extra[0]);
// Adapt the description string if custom platform/language is set.
if (hasCustomLanguage || hasCustomPlatform || hasExtraDesc) {
dg.description += " (";
if (hasCustomLanguage)
dg.description += Common::getLanguageDescription(dg.language);
if (hasCustomPlatform) {
if (hasCustomLanguage)
dg.description += "/";
dg.description += Common::getPlatformDescription(dg.platform);
}
if (hasExtraDesc) {
if (hasCustomPlatform || hasCustomLanguage)
dg.description += "/";
dg.description += elem->extra;
}
dg.description += ")";
}
dg.updateDesc(elem->extra); // Append extra information to the description.
// Insert the 'enhanced' game data into the candidate list
detectedGames.push_back(dg);