ACHIEVEMENTS: Allow to override the default achievements platform

This commit is contained in:
scemino 2024-04-23 13:26:24 +02:00 committed by Eugene Sandulenko
parent dca3c4179b
commit 599adef9d5
2 changed files with 22 additions and 8 deletions

View File

@ -138,6 +138,17 @@ Common::KeymapArray MetaEngine::initKeymaps(const char *target) const {
return Keymap::arrayOf(engineKeyMap);
}
Common::AchievementsPlatform MetaEngine::getAchievementsPlatform(const Common::String &target) const {
Common::String extra = ConfMan.get("extra", target);
if (extra.contains("GOG")) {
return Common::GALAXY_ACHIEVEMENTS;
}
if (extra.contains("Steam")) {
return Common::STEAM_ACHIEVEMENTS;
}
return Common::UNK_ACHIEVEMENTS;
}
const Common::AchievementsInfo MetaEngine::getAchievementsInfo(const Common::String &target) const {
const Common::AchievementDescriptionList* achievementDescriptionList = getAchievementDescriptionList();
if (achievementDescriptionList == nullptr) {
@ -146,13 +157,7 @@ const Common::AchievementsInfo MetaEngine::getAchievementsInfo(const Common::Str
Common::String gameId = ConfMan.get("gameid", target);
Common::AchievementsPlatform platform = Common::UNK_ACHIEVEMENTS;
Common::String extra = ConfMan.get("extra", target);
if (extra.contains("GOG")) {
platform = Common::GALAXY_ACHIEVEMENTS;
} else if (extra.contains("Steam")) {
platform = Common::STEAM_ACHIEVEMENTS;
}
const Common::AchievementsPlatform platform = getAchievementsPlatform(target);
// "(gameId, platform) -> result" search
Common::AchievementsInfo result;
@ -403,7 +408,7 @@ SaveStateList MetaEngine::listSaves(const char *target, bool saveMode) const {
SaveStateDescriptor desc(this, autosaveSlot, dummyAutosave);
desc.setWriteProtectedFlag(true);
desc.setDeletableFlag(false);
saveList.push_back(desc);
Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());

View File

@ -493,6 +493,15 @@ public:
kSavesUseExtendedFormat
};
/**
* Return the achievements platform to use for the specified target.
*
* @param target Name of a config manager target.
*
* @return The achievements platform to use for an engine plugin and target.
*/
virtual Common::AchievementsPlatform getAchievementsPlatform(const Common::String &target) const;
/**
* Return a list of achievement descriptions for the specified target.
*