From ec2a50b746ba36b2cce917ba1a110026aee028d0 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 16 Apr 2021 14:14:40 +0200 Subject: [PATCH] AD: Implemented AGDF_WARNING flag --- engines/advancedDetector.cpp | 10 ++++++++-- engines/advancedDetector.h | 14 ++++++++------ engines/engine.cpp | 5 +++-- engines/engine.h | 2 +- engines/game.h | 3 ++- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp index 949ba648223..88c763756f5 100644 --- a/engines/advancedDetector.cpp +++ b/engines/advancedDetector.cpp @@ -171,7 +171,7 @@ DetectedGame AdvancedMetaEngineDetection::toDetectedGame(const ADDetectedGame &a extra = desc->extra; } - DetectedGame game(getEngineId(), desc->gameId, title, desc->language, desc->platform, extra, desc->flags & ADGF_UNSUPPORTED); + DetectedGame game(getEngineId(), desc->gameId, title, desc->language, desc->platform, extra, ((desc->flags & (ADGF_UNSUPPORTED | ADGF_WARNING)) != 0)); game.hasUnknownFiles = adGame.hasUnknownFiles; game.matchedFiles = adGame.matchedFiles; game.preferredTarget = generatePreferredTarget(desc, _maxAutogenLength); @@ -183,6 +183,8 @@ DetectedGame AdvancedMetaEngineDetection::toDetectedGame(const ADDetectedGame &a game.gameSupportLevel = kTestingGame; else if (desc->flags & ADGF_UNSUPPORTED) game.gameSupportLevel = kUnsupportedGame; + else if (desc->flags & ADGF_WARNING) + game.gameSupportLevel = kWarningGame; game.setGUIOptions(desc->guiOptions + _guiOptions); game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(desc->language)); @@ -378,7 +380,11 @@ Common::Error AdvancedMetaEngineDetection::createInstance(OSystem *syst, Engine if (((gameDescriptor.gameSupportLevel == kUnstableGame || (gameDescriptor.gameSupportLevel == kTestingGame && showTestingWarning))) - && !Engine::warnUserAboutUnsupportedGame()) + && !Engine::warnUserAboutUnsupportedGame("")) + return Common::kUserCanceled; + + if (gameDescriptor.gameSupportLevel == kWarningGame + && !Engine::warnUserAboutUnsupportedGame(gameDescriptor.extra)) return Common::kUserCanceled; if (gameDescriptor.gameSupportLevel == kUnsupportedGame) { diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h index 42e18bab928..f2edff84401 100644 --- a/engines/advancedDetector.h +++ b/engines/advancedDetector.h @@ -84,13 +84,15 @@ struct ADGameFileDescription { */ enum ADGameFlags { ADGF_NO_FLAGS = 0, ///< No flags. - ADGF_REMASTERED = (1 << 18), ///< Add "-remastered' to gameid. - ADGF_AUTOGENTARGET = (1 << 19), ///< Automatically generate gameid from @ref ADGameDescription::extra. - ADGF_UNSTABLE = (1 << 20), ///< Flag to designate not yet officially supported games that are not fit for public testing. - ADGF_TESTING = (1 << 21), ///< Flag to designate not yet officially supported games that are fit for public testing. - ADGF_PIRATED = (1 << 22), ///< Flag to designate well-known pirated versions with cracks. - ADGF_UNSUPPORTED = (1 << 23), /*!< Flag to mark certain versions (like badly protected full games as demos) not to be run for various reasons. + ADGF_REMASTERED = (1 << 17), ///< Add "-remastered' to gameid. + ADGF_AUTOGENTARGET = (1 << 18), ///< Automatically generate gameid from @ref ADGameDescription::extra. + ADGF_UNSTABLE = (1 << 19), ///< Flag to designate not yet officially supported games that are not fit for public testing. + ADGF_TESTING = (1 << 20), ///< Flag to designate not yet officially supported games that are fit for public testing. + ADGF_PIRATED = (1 << 21), ///< Flag to designate well-known pirated versions with cracks. + ADGF_UNSUPPORTED = (1 << 22), /*!< Flag to mark certain versions (like badly protected full games as demos) not to be run for various reasons. A custom message can be provided in the @ref ADGameDescription::extra field. */ + ADGF_WARNING = (1 << 23), /*!< Flag to mark certain versions to show confirmation warning before proceeding. + A custom message should be provided in the @ref ADGameDescription::extra field. */ ADGF_ADDENGLISH = (1 << 24), ///< Always add English as a language option. ADGF_MACRESFORK = (1 << 25), ///< Calculate the MD5 for this entry from the resource fork. ADGF_USEEXTRAASTITLE = (1 << 26), ///< Use @ref ADGameDescription::extra as the main game title, not gameid. diff --git a/engines/engine.cpp b/engines/engine.cpp index 24056008386..39e7b48fe05 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -644,9 +644,10 @@ void Engine::openMainMenuDialog() { syncSoundSettings(); } -bool Engine::warnUserAboutUnsupportedGame() { +bool Engine::warnUserAboutUnsupportedGame(Common::String msg) { if (ConfMan.getBool("enable_unsupported_game_warning")) { - GUI::MessageDialog alert(_("WARNING: The game you are about to start is" + GUI::MessageDialog alert(!msg.empty() ? _("WARNING: ") + Common::U32String(msg) + _(" Shall we still run the game?") : + _("WARNING: The game you are about to start is" " not yet fully supported by ScummVM. As such, it is likely to be" " unstable, and any saved game you make might not work in future" " versions of ScummVM."), _("Start anyway"), _("Cancel")); diff --git a/engines/engine.h b/engines/engine.h index 8113b4cce93..2bd3588c154 100644 --- a/engines/engine.h +++ b/engines/engine.h @@ -546,7 +546,7 @@ public: * * @return True if the user chooses to start anyway, false otherwise. */ - static bool warnUserAboutUnsupportedGame(); + static bool warnUserAboutUnsupportedGame(Common::String msg); /** * Display an error message to the user that the game is not supported. diff --git a/engines/game.h b/engines/game.h index be12153b08e..8283f8cba1d 100644 --- a/engines/game.h +++ b/engines/game.h @@ -94,7 +94,8 @@ enum GameSupportLevel { kStableGame = 0, // the game is fully supported kTestingGame, // the game is not supposed to end up in releases yet but is ready for public testing kUnstableGame, // the game is not even ready for public testing yet - kUnsupportedGame // we don't want to support the game + kUnsupportedGame, // we don't want to support the game + kWarningGame // we want to ask user to proceed and provide them with an explanation };