diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/EventRecorder.cpp | 4 | ||||
-rw-r--r-- | gui/editgamedialog.cpp | 8 | ||||
-rw-r--r-- | gui/editgamedialog.h | 4 | ||||
-rw-r--r-- | gui/launcher.cpp | 72 | ||||
-rw-r--r-- | gui/launcher.h | 2 | ||||
-rw-r--r-- | gui/massadd.cpp | 50 | ||||
-rw-r--r-- | gui/massadd.h | 5 | ||||
-rw-r--r-- | gui/recorderdialog.cpp | 4 |
8 files changed, 61 insertions, 88 deletions
diff --git a/gui/EventRecorder.cpp b/gui/EventRecorder.cpp index 849405410a..560df0ec35 100644 --- a/gui/EventRecorder.cpp +++ b/gui/EventRecorder.cpp @@ -600,13 +600,13 @@ void EventRecorder::setFileHeader() { return; } TimeDate t; - GameDescriptor desc = EngineMan.findGame(ConfMan.getActiveDomainName()); + PlainGameDescriptor desc = EngineMan.findGame(ConfMan.getActiveDomainName()); g_system->getTimeAndDate(t); if (_author.empty()) { setAuthor("Unknown Author"); } if (_name.empty()) { - g_eventRec.setName(Common::String::format("%.2d.%.2d.%.4d ", t.tm_mday, t.tm_mon, 1900 + t.tm_year) + desc.description()); + g_eventRec.setName(Common::String::format("%.2d.%.2d.%.4d ", t.tm_mday, t.tm_mon, 1900 + t.tm_year) + desc.description); } _playbackFile->getHeader().author = _author; _playbackFile->getHeader().notes = _desc; diff --git a/gui/editgamedialog.cpp b/gui/editgamedialog.cpp index fa0d3fac9b..80fb41fad1 100644 --- a/gui/editgamedialog.cpp +++ b/gui/editgamedialog.cpp @@ -95,7 +95,7 @@ protected: } }; -EditGameDialog::EditGameDialog(const String &domain, const String &desc) +EditGameDialog::EditGameDialog(const String &domain) : OptionsDialog(domain, "GameOptions") { // Retrieve all game specific options. const Plugin *plugin = nullptr; @@ -106,7 +106,7 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc) gameId = domain; // Retrieve the plugin, since we need to access the engine's MetaEngine // implementation. - EngineMan.findGame(gameId, &plugin); + PlainGameDescriptor pgd = EngineMan.findGame(gameId, &plugin); if (plugin) { _engineOptions = plugin->get<MetaEngine>().getExtraGuiOptions(domain); } else { @@ -120,8 +120,8 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc) // GAME: Determine the description string String description(ConfMan.get("description", domain)); - if (description.empty() && !desc.empty()) { - description = desc; + if (description.empty() && pgd.description) { + description = pgd.description; } // GUI: Add tab widget diff --git a/gui/editgamedialog.h b/gui/editgamedialog.h index a317e364c6..7c6a08eb3c 100644 --- a/gui/editgamedialog.h +++ b/gui/editgamedialog.h @@ -40,8 +40,6 @@ class StaticTextWidget; class EditTextWidget; class SaveLoadChooser; -Common::String addGameToConf(const GameDescriptor &result); - /* * A dialog that allows the user to edit a config game entry. * TODO: add widgets for some/all of the following @@ -62,7 +60,7 @@ class EditGameDialog : public OptionsDialog { typedef Common::String String; typedef Common::Array<Common::String> StringArray; public: - EditGameDialog(const String &domain, const String &desc); + EditGameDialog(const String &domain); void open(); virtual void apply(); diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 857d7d001a..7a37a7d3be 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" @@ -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, 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<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 diff --git a/gui/launcher.h b/gui/launcher.h index 08413fe3d2..9f0a1c8e95 100644 --- a/gui/launcher.h +++ b/gui/launcher.h @@ -38,8 +38,6 @@ class StaticTextWidget; class EditTextWidget; class SaveLoadChooser; -Common::String addGameToConf(const GameDescriptor &result); - class LauncherDialog : public Dialog { typedef Common::String String; typedef Common::Array<Common::String> StringArray; diff --git a/gui/massadd.cpp b/gui/massadd.cpp index db569fac82..8bc5a10720 100644 --- a/gui/massadd.cpp +++ b/gui/massadd.cpp @@ -28,10 +28,7 @@ #include "common/taskbar.h" #include "common/translation.h" -#include "gui/launcher.h" // For addGameToConf() #include "gui/massadd.h" -#include "gui/widget.h" -#include "gui/widgets/list.h" #ifndef DISABLE_MASS_ADD namespace GUI { @@ -120,14 +117,14 @@ MassAddDialog::MassAddDialog(const Common::FSNode &startDir) } struct GameTargetLess { - bool operator()(const GameDescriptor &x, const GameDescriptor &y) const { - return x.preferredtarget().compareToIgnoreCase(y.preferredtarget()) < 0; + bool operator()(const DetectedGame &x, const DetectedGame &y) const { + return x.preferredTarget.compareToIgnoreCase(y.preferredTarget) < 0; } }; struct GameDescLess { - bool operator()(const GameDescriptor &x, const GameDescriptor &y) const { - return x.description().compareToIgnoreCase(y.description()) < 0; + bool operator()(const DetectedGame &x, const DetectedGame &y) const { + return x.description.compareToIgnoreCase(y.description) < 0; } }; @@ -143,13 +140,13 @@ void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data if (cmd == kOkCmd) { // Sort the detected games. This is not strictly necessary, but nice for // people who want to edit their config file by hand after a mass add. - sort(_games.begin(), _games.end(), GameTargetLess()); + Common::sort(_games.begin(), _games.end(), GameTargetLess()); // Add all the detected games to the config - for (GameList::iterator iter = _games.begin(); iter != _games.end(); ++iter) { + for (DetectedGames::iterator iter = _games.begin(); iter != _games.end(); ++iter) { debug(1, " Added gameid '%s', desc '%s'\n", - (*iter)["gameid"].c_str(), - (*iter)["description"].c_str()); - (*iter)["gameid"] = addGameToConf(*iter); + iter->gameId.c_str(), + iter->description.c_str()); + iter->gameId = EngineMan.createTargetForGame(*iter); } // Write everything to disk @@ -157,8 +154,8 @@ void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data // And scroll to first detected game if (!_games.empty()) { - sort(_games.begin(), _games.end(), GameDescLess()); - ConfMan.set("temp_selection", _games.front().gameid()); + Common::sort(_games.begin(), _games.end(), GameDescLess()); + ConfMan.set("temp_selection", _games.front().gameId); } close(); @@ -187,7 +184,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 +197,10 @@ 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 DetectedGame &result = *cand; + Common::String path = dir.getPath(); // Remove trailing slashes @@ -205,6 +209,9 @@ void MassAddDialog::handleTickle() { // Check for existing config entries for this path/gameid/lang/platform combination if (_pathToTargets.contains(path)) { + const char *resultPlatformCode = Common::getPlatformCode(result.platform); + const char *resultLanguageCode = Common::getLanguageCode(result.language); + bool duplicate = false; const StringArray &targets = _pathToTargets[path]; for (StringArray::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) { @@ -212,9 +219,9 @@ void MassAddDialog::handleTickle() { Common::ConfigManager::Domain *dom = ConfMan.getDomain(*iter); assert(dom); - if ((*dom)["gameid"] == result["gameid"] && - (*dom)["platform"] == result["platform"] && - (*dom)["language"] == result["language"]) { + if ((*dom)["gameid"] == result.gameId && + (*dom)["platform"] == resultPlatformCode && + (*dom)["language"] == resultLanguageCode) { duplicate = true; break; } @@ -224,10 +231,9 @@ void MassAddDialog::handleTickle() { break; // Skip duplicates } } - result["path"] = path; _games.push_back(result); - _list->append(result.description()); + _list->append(result.description); } diff --git a/gui/massadd.h b/gui/massadd.h index 116a420d79..b81a6046e2 100644 --- a/gui/massadd.h +++ b/gui/massadd.h @@ -24,6 +24,7 @@ #define MASSADD_DIALOG_H #include "gui/dialog.h" +#include "gui/widgets/list.h" #include "common/fs.h" #include "common/hashmap.h" #include "common/stack.h" @@ -44,13 +45,13 @@ public: Common::String getFirstAddedTarget() const { if (!_games.empty()) - return _games.front().gameid(); + return _games.front().gameId; return Common::String(); } private: Common::Stack<Common::FSNode> _scanStack; - GameList _games; + DetectedGames _games; /** * Map each path occuring in the config file to the target(s) using that path. diff --git a/gui/recorderdialog.cpp b/gui/recorderdialog.cpp index cd89b58f00..7a2cd048f4 100644 --- a/gui/recorderdialog.cpp +++ b/gui/recorderdialog.cpp @@ -167,9 +167,9 @@ void RecorderDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat case kRecordCmd: { TimeDate t; Common::String gameId = ConfMan.get("gameid", _target); - GameDescriptor desc = EngineMan.findGame(gameId); + PlainGameDescriptor desc = EngineMan.findGame(gameId); g_system->getTimeAndDate(t); - EditRecordDialog editDlg(_("Unknown Author"), Common::String::format("%.2d.%.2d.%.4d ", t.tm_mday, t.tm_mon, 1900 + t.tm_year) + desc.description(), ""); + EditRecordDialog editDlg(_("Unknown Author"), Common::String::format("%.2d.%.2d.%.4d ", t.tm_mday, t.tm_mon, 1900 + t.tm_year) + desc.description, ""); if (editDlg.runModal() != kOKCmd) { return; } |