From cf1ebf29516bd74927fd7b632b72fd8973f72e98 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sat, 2 Dec 2017 17:14:22 +0100 Subject: ENGINES: Add unknown game variants to the game detector results --- gui/launcher.cpp | 20 ++++++++++++++------ gui/massadd.cpp | 13 +++++++++---- 2 files changed, 23 insertions(+), 10 deletions(-) (limited to 'gui') diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 857d7d001a..b14be6c11e 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -45,6 +45,7 @@ #include "gui/EventRecorder.h" #endif #include "gui/saveload.h" +#include "engines/unknown-game-dialog.h" #include "gui/widgets/edittext.h" #include "gui/widgets/list.h" #include "gui/widgets/tab.h" @@ -573,7 +574,17 @@ bool LauncherDialog::doGameDetection(const Common::String &path) { // ...so let's determine a list of candidates, games that // could be contained in the specified directory. - GameList candidates(EngineMan.detectGames(files, true)); + DetectionResults detectionResults = EngineMan.detectGames(files); + + if (detectionResults.foundUnknownGames()) { + Common::String report = detectionResults.generateUnknownGameReport(false, 80); + g_system->logMessage(LogMessageType::kInfo, report.c_str()); + + UnknownGameDialog dialog(detectionResults); + dialog.runModal(); + } + + Common::Array candidates = detectionResults.listRecognizedGames(); int idx; if (candidates.empty()) { @@ -589,17 +600,14 @@ bool LauncherDialog::doGameDetection(const Common::String &path) { // Display the candidates to the user and let her/him pick one StringArray list; for (idx = 0; idx < (int)candidates.size(); idx++) - list.push_back(candidates[idx].description()); + list.push_back(candidates[idx].matchedGame.description()); ChooserDialog dialog(_("Pick the game:")); dialog.setList(list); idx = dialog.runModal(); } if (0 <= idx && idx < (int)candidates.size()) { - GameDescriptor result = candidates[idx]; - - // TODO: Change the detectors to set "path" ! - result["path"] = dir.getPath(); + const GameDescriptor &result = candidates[idx].matchedGame; Common::String domain = addGameToConf(result); diff --git a/gui/massadd.cpp b/gui/massadd.cpp index db569fac82..2774d476db 100644 --- a/gui/massadd.cpp +++ b/gui/massadd.cpp @@ -187,7 +187,12 @@ void MassAddDialog::handleTickle() { } // Run the detector on the dir - GameList candidates(EngineMan.detectGames(files)); + DetectionResults detectionResults = EngineMan.detectGames(files); + + if (detectionResults.foundUnknownGames()) { + Common::String report = detectionResults.generateUnknownGameReport(false, 80); + g_system->logMessage(LogMessageType::kInfo, report.c_str()); + } // Just add all detected games / game variants. If we get more than one, // that either means the directory contains multiple games, or the detector @@ -195,8 +200,9 @@ void MassAddDialog::handleTickle() { // case, let the user choose which entries he wants to keep. // // However, we only add games which are not already in the config file. - for (GameList::const_iterator cand = candidates.begin(); cand != candidates.end(); ++cand) { - GameDescriptor result = *cand; + DetectedGames candidates = detectionResults.listRecognizedGames(); + for (DetectedGames::const_iterator cand = candidates.begin(); cand != candidates.end(); ++cand) { + const GameDescriptor &result = cand->matchedGame; Common::String path = dir.getPath(); // Remove trailing slashes @@ -224,7 +230,6 @@ void MassAddDialog::handleTickle() { break; // Skip duplicates } } - result["path"] = path; _games.push_back(result); _list->append(result.description()); -- cgit v1.2.3