diff options
-rw-r--r-- | base/plugins.cpp | 31 | ||||
-rw-r--r-- | base/plugins.h | 5 | ||||
-rw-r--r-- | engines/scumm/plugin.cpp | 31 |
3 files changed, 39 insertions, 28 deletions
diff --git a/base/plugins.cpp b/base/plugins.cpp index 0f1fc62b18..80f19bd775 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -71,6 +71,37 @@ PluginRegistrator::PluginRegistrator(const char *name, GameList games, GameIDQue #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 class StaticPlugin : public Plugin { PluginRegistrator *_plugin; diff --git a/base/plugins.h b/base/plugins.h index 5cc362ca58..678d2f5f6d 100644 --- a/base/plugins.h +++ b/base/plugins.h @@ -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); }; diff --git a/engines/scumm/plugin.cpp b/engines/scumm/plugin.cpp index f3f337370d..b452f09d25 100644 --- a/engines/scumm/plugin.cpp +++ b/engines/scumm/plugin.cpp @@ -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); |