added a listTargets() function (not yet used, soon) and some cleanup

svn-id: r10865
This commit is contained in:
Max Horn 2003-10-17 16:04:46 +00:00
parent df7cda84d3
commit ae6e6a4885
2 changed files with 30 additions and 21 deletions

View file

@ -207,35 +207,45 @@ GameDetector::GameDetector() {
_plugin = 0; _plugin = 0;
} }
void GameDetector::list_games() { /** List all supported games, i.e. all games which any loaded plugin supports. */
// FIXME / TODO: config rewrite void listGames() {
// Right now this lists all known built-in targets; and also for each of
// those it tells the user if the target is "configured".
// To me this seems like an ill mix of two different functionalities.
// IMHO we should split this into two seperate commands/options:
// 1) List all built-in gameids (e.g. monkey, atlantis, ...) similiar to
// what this code does, but without the "Config" column.
// 2) List all available (configured) targets, including those with custom
// names, e.g. "monkey-mac", "skycd-demo", ...
const PluginList &plugins = PluginManager::instance().getPlugins(); const PluginList &plugins = PluginManager::instance().getPlugins();
printf("Game Full Title \n" printf("Game ID Full Title \n"
"---------------- ------------------------------------------------------\n"); "-------------------- ------------------------------------------------------\n");
PluginList::ConstIterator iter = plugins.begin(); PluginList::ConstIterator iter = plugins.begin();
for (iter = plugins.begin(); iter != plugins.end(); ++iter) { for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
GameList list = (*iter)->getSupportedGames(); GameList list = (*iter)->getSupportedGames();
for (GameList::Iterator v = list.begin(); v != list.end(); ++v) { for (GameList::Iterator v = list.begin(); v != list.end(); ++v) {
#if 1 printf("%-20s %s\n", v->gameName, v->description);
printf("%-17s%-56s\n", v->gameName, v->description);
#else
const char *config = (g_config->has_domain(v->gameName)) ? "Yes" : "";
printf("%-17s%-56s%s\n", v->gameName, v->description, config);
#endif
} }
} }
} }
/** List all targets which are configured in the config file. */
void listTargets() {
using namespace Common;
const ConfigManager::DomainMap &domains = ConfMan.getGameDomains();
printf("Target Description \n"
"-------------------- ------------------------------------------------------\n");
ConfigManager::DomainMap::ConstIterator iter = domains.begin();
for (iter = domains.begin(); iter != domains.end(); ++iter) {
String name(iter->_key);
String description(iter->_value.get("description"));
if (description.isEmpty()) {
GameSettings g = GameDetector::findGame(name);
if (g.description)
description = g.description;
}
printf("%-20s %s\n", name.c_str(), description.c_str());
}
}
GameSettings GameDetector::findGame(const String &gameName, const Plugin **plugin) { GameSettings GameDetector::findGame(const String &gameName, const Plugin **plugin) {
// Find the GameSettings for this target // Find the GameSettings for this target
const PluginList &plugins = PluginManager::instance().getPlugins(); const PluginList &plugins = PluginManager::instance().getPlugins();
@ -381,7 +391,7 @@ void GameDetector::parseCommandLine(int argc, char **argv) {
#endif #endif
case 'z': case 'z':
CHECK_OPTION(); CHECK_OPTION();
list_games(); listGames();
exit(0); exit(0);
case '-': case '-':
// Long options. Let the fun begin! // Long options. Let the fun begin!
@ -393,7 +403,7 @@ void GameDetector::parseCommandLine(int argc, char **argv) {
ConfMan.set("platform", platform); ConfMan.set("platform", platform);
break; break;
} }
if (!strncmp(s, "no-", 3)) { if (!strncmp(s, "no-", 3)) {
long_option_value = false; long_option_value = false;

View file

@ -91,7 +91,6 @@ public:
protected: protected:
bool detectGame(void); bool detectGame(void);
void list_games();
}; };
#endif #endif