diff options
Diffstat (limited to 'gui/launcher.cpp')
-rw-r--r-- | gui/launcher.cpp | 72 |
1 files changed, 21 insertions, 51 deletions
diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 4fe1ae79c8..214dc30834 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -45,6 +45,7 @@ #include "gui/EventRecorder.h" #endif #include "gui/saveload.h" +#include "gui/unknown-game-dialog.h" #include "gui/widgets/edittext.h" #include "gui/widgets/list.h" #include "gui/widgets/tab.h" @@ -266,9 +267,9 @@ void LauncherDialog::updateListing() { if (gameid.empty()) gameid = iter->_key; if (description.empty()) { - GameDescriptor g = EngineMan.findGame(gameid); - if (g.contains("description")) - description = g.description(); + PlainGameDescriptor g = EngineMan.findGame(gameid); + if (g.description) + description = g.description; } if (description.empty()) { @@ -375,45 +376,6 @@ void LauncherDialog::addGame() { } while (looping); } -Common::String addGameToConf(const GameDescriptor &result) { - // The auto detector or the user made a choice. - // Pick a domain name which does not yet exist (after all, we - // are *adding* a game to the config, not replacing). - Common::String domain = result.preferredtarget(); - - assert(!domain.empty()); - if (ConfMan.hasGameDomain(domain)) { - int suffixN = 1; - Common::String gameid(domain); - - while (ConfMan.hasGameDomain(domain)) { - domain = gameid + Common::String::format("-%d", suffixN); - suffixN++; - } - } - - // Add the name domain - ConfMan.addGameDomain(domain); - - // Copy all non-empty key/value pairs into the new domain - for (GameDescriptor::const_iterator iter = result.begin(); iter != result.end(); ++iter) { - if (!iter->_value.empty() && iter->_key != "preferredtarget") - ConfMan.set(iter->_key, iter->_value, domain); - } - - // TODO: Setting the description field here has the drawback - // that the user does never notice when we upgrade our descriptions. - // It might be nice ot leave this field empty, and only set it to - // a value when the user edits the description string. - // However, at this point, that's impractical. Once we have a method - // to query all backends for the proper & full description of a given - // game target, we can change this (currently, you can only query - // for the generic gameid description; it's not possible to obtain - // a description which contains extended information like language, etc.). - - return domain; -} - void LauncherDialog::removeGame(int item) { MessageDialog alert(_("Do you really want to remove this game configuration?"), _("Yes"), _("No")); @@ -442,7 +404,8 @@ void LauncherDialog::editGame(int item) { String gameId(ConfMan.get("gameid", _domains[item])); if (gameId.empty()) gameId = _domains[item]; - EditGameDialog editDialog(_domains[item], EngineMan.findGame(gameId).description()); + + EditGameDialog editDialog(_domains[item]); if (editDialog.runModal() > 0) { // User pressed OK, so make changes permanent @@ -573,7 +536,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)); + 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<DetectedGame> candidates = detectionResults.listRecognizedGames(); int idx; if (candidates.empty()) { @@ -589,22 +562,19 @@ 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].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 DetectedGame &result = candidates[idx]; - Common::String domain = addGameToConf(result); + Common::String domain = EngineMan.createTargetForGame(result); // Display edit dialog for the new entry - EditGameDialog editDialog(domain, result.description()); + EditGameDialog editDialog(domain); if (editDialog.runModal() > 0) { // User pressed OK, so make changes permanent |