aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--base/commandLine.cpp44
-rw-r--r--base/plugins.cpp51
-rw-r--r--engines/metaengine.h7
-rw-r--r--gui/launcher.cpp54
-rw-r--r--gui/launcher.h2
-rw-r--r--gui/massadd.cpp5
-rw-r--r--gui/massadd.h1
7 files changed, 64 insertions, 100 deletions
diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index e1539d7a3e..02c3d1c454 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -881,45 +881,6 @@ static GameList getGameList(const Common::FSNode &dir) {
return candidates;
}
-namespace {
-
-static void addStringToConf(const Common::String &key, const Common::String &value, const Common::String &domain) {
- if (!value.empty())
- ConfMan.set(key, value, domain);
-}
-
-} // End of anonymous namespace
-
-static bool addGameToConf(const GameDescriptor &gd) {
- const Common::String &domain = gd.preferredTarget;
-
- // If game has already been added, don't add
- if (ConfMan.hasGameDomain(domain))
- return false;
-
- // Add the name domain
- ConfMan.addGameDomain(domain);
-
- // Copy all non-empty relevant values into the new domain
- // FIXME: Factor out
- addStringToConf("gameid", gd.gameId, domain);
- addStringToConf("description", gd.description, domain);
- addStringToConf("language", Common::getLanguageCode(gd.language), domain);
- addStringToConf("platform", Common::getPlatformCode(gd.platform), domain);
- addStringToConf("path", gd.path, domain);
- addStringToConf("extra", gd.extra, domain);
- addStringToConf("guioptions", gd.getGUIOptions(), domain);
-
- // Display added game info
- printf("Game Added: \n GameID: %s\n Name: %s\n Language: %s\n Platform: %s\n",
- gd.gameId.c_str(),
- gd.description.c_str(),
- Common::getLanguageDescription(gd.language),
- Common::getPlatformDescription(gd.platform));
-
- return true;
-}
-
static GameList recListGames(const Common::FSNode &dir, const Common::String &gameId, bool recursive) {
GameList list = getGameList(dir);
@@ -971,11 +932,12 @@ static int recAddGames(const Common::FSNode &dir, const Common::String &game, bo
for (GameList::iterator v = list.begin(); v != list.end(); ++v) {
if (v->gameId != game && !game.empty()) {
printf("Found %s, only adding %s per --game option, ignoring...\n", v->gameId.c_str(), game.c_str());
- } else if (!addGameToConf(*v)) {
- // TODO Is it reall the case that !addGameToConf iff already added?
+ } else if (ConfMan.hasGameDomain(v->preferredTarget)) {
+ // TODO Better check for game already added?
printf("Found %s, but has already been added, skipping\n", v->gameId.c_str());
} else {
printf("Found %s, adding...\n", v->gameId.c_str());
+ EngineMan.createTargetForGame(*v);
count++;
}
}
diff --git a/base/plugins.cpp b/base/plugins.cpp
index 61dae910f9..1bfb929950 100644
--- a/base/plugins.cpp
+++ b/base/plugins.cpp
@@ -545,6 +545,57 @@ const PluginList &EngineManager::getPlugins() const {
return PluginManager::instance().getPlugins(PLUGIN_TYPE_ENGINE);
}
+namespace {
+
+void addStringToConf(const Common::String &key, const Common::String &value, const Common::String &domain) {
+ if (!value.empty())
+ ConfMan.set(key, value, domain);
+}
+
+} // End of anonymous namespace
+
+Common::String EngineManager::createTargetForGame(const GameDescriptor &game) {
+ // 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 = game.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 relevant values into the new domain
+ addStringToConf("gameid", game.gameId, domain);
+ addStringToConf("description", game.description, domain);
+ addStringToConf("language", Common::getLanguageCode(game.language), domain);
+ addStringToConf("platform", Common::getPlatformCode(game.platform), domain);
+ addStringToConf("path", game.path, domain);
+ addStringToConf("extra", game.extra, domain);
+ addStringToConf("guioptions", game.getGUIOptions(), 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 to 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;
+}
+
// Music plugins
#include "audio/musicplugin.h"
diff --git a/engines/metaengine.h b/engines/metaengine.h
index 74eb367200..6e8ab16af8 100644
--- a/engines/metaengine.h
+++ b/engines/metaengine.h
@@ -271,6 +271,13 @@ public:
PlainGameDescriptor findGame(const Common::String &gameName, const Plugin **plugin = NULL) const;
DetectionResults detectGames(const Common::FSList &fslist) const;
const PluginList &getPlugins() const;
+
+ /**
+ * Create a target from the supplied game descriptor
+ *
+ * Returns the created target name.
+ */
+ Common::String createTargetForGame(const GameDescriptor &game);
};
/** Convenience shortcut for accessing the engine manager. */
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 4edd3527f4..67a62ad61e 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -376,58 +376,6 @@ void LauncherDialog::addGame() {
} while (looping);
}
-namespace {
-
-static void addStringToConf(const Common::String &key, const Common::String &value, const Common::String &domain) {
- if (!value.empty())
- ConfMan.set(key, value, domain);
-}
-
-} // End of anonymous namespace
-
-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 relevant values into the new domain
- // FIXME: Factor out
- addStringToConf("gameid", result.gameId, domain);
- addStringToConf("description", result.description, domain);
- addStringToConf("language", Common::getLanguageCode(result.language), domain);
- addStringToConf("platform", Common::getPlatformCode(result.platform), domain);
- addStringToConf("path", result.path, domain);
- addStringToConf("extra", result.extra, domain);
- addStringToConf("guioptions", result.getGUIOptions(), 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"));
@@ -623,7 +571,7 @@ bool LauncherDialog::doGameDetection(const Common::String &path) {
if (0 <= idx && idx < (int)candidates.size()) {
const GameDescriptor &result = candidates[idx].matchedGame;
- Common::String domain = addGameToConf(result);
+ Common::String domain = EngineMan.createTargetForGame(result);
// Display edit dialog for the new entry
EditGameDialog editDialog(domain);
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 7c54c503a3..56b15ecfd7 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 {
@@ -149,7 +146,7 @@ void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
debug(1, " Added gameid '%s', desc '%s'\n",
iter->gameId.c_str(),
iter->description.c_str());
- iter->gameId = addGameToConf(*iter);
+ iter->gameId = EngineMan.createTargetForGame(*iter);
}
// Write everything to disk
diff --git a/gui/massadd.h b/gui/massadd.h
index 58071cda0a..b954c87161 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"