[Scummvm-cvs-logs] SF.net SVN: scummvm: [21569] scummvm/trunk/base

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Apr 2 14:07:10 CEST 2006


Revision: 21569
Author:   fingolfin
Date:     2006-04-02 14:06:49 -0700 (Sun, 02 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21569&view=rev

Log Message:
-----------
Move handling of --list-targets and --list-games to a later point (after plugin & config file loading), to make them work properly again.

Modified Paths:
--------------
    scummvm/trunk/base/gameDetector.cpp
    scummvm/trunk/base/gameDetector.h
    scummvm/trunk/base/main.cpp
Modified: scummvm/trunk/base/gameDetector.cpp
===================================================================
--- scummvm/trunk/base/gameDetector.cpp	2006-04-02 20:49:03 UTC (rev 21568)
+++ scummvm/trunk/base/gameDetector.cpp	2006-04-02 21:06:49 UTC (rev 21569)
@@ -252,49 +252,6 @@
 	_plugin = 0;
 }
 
-/** List all supported game IDs, i.e. all games which any loaded plugin supports. */
-void listGames() {
-	const PluginList &plugins = PluginManager::instance().getPlugins();
-
-	printf("Game ID              Full Title                                            \n"
-	       "-------------------- ------------------------------------------------------\n");
-
-	PluginList::const_iterator iter = plugins.begin();
-	for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
-		GameList list = (*iter)->getSupportedGames();
-		for (GameList::iterator v = list.begin(); v != list.end(); ++v) {
-			printf("%-20s %s\n", v->gameid.c_str(), v->description.c_str());
-		}
-	}
-}
-
-/** 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::const_iterator iter = domains.begin();
-	for (iter = domains.begin(); iter != domains.end(); ++iter) {
-		String name(iter->_key);
-		String description(iter->_value.get("description"));
-
-		if (description.empty()) {
-			// FIXME: At this point, we should check for a "gameid" override
-			// to find the proper desc. In fact, the platform probably should
-			// be taken into account, too.
-			String gameid(name);
-			GameDescriptor g = GameDetector::findGame(gameid);
-			if (g.description.size() > 0)
-				description = g.description;
-		}
-
-		printf("%-20s %s\n", name.c_str(), description.c_str());
-	}
-}
-
 GameDescriptor GameDetector::findGame(const String &gameName, const Plugin **plugin) {
 	// Find the GameDescriptor for this target
 	const PluginList &plugins = PluginManager::instance().getPlugins();
@@ -372,7 +329,7 @@
 	}
 
 
-void GameDetector::parseCommandLine(Common::StringMap &settings, int argc, char **argv) {
+Common::String GameDetector::parseCommandLine(Common::StringMap &settings, int argc, char **argv) {
 	const char *s, *s2;
 	
 	// argv[0] contains the name of the executable.
@@ -415,13 +372,11 @@
 			END_OPTION
 
 			DO_OPTION_CMD('t', "list-targets")
-				listTargets();
-				exit(0);
+				return "list-targets";
 			END_OPTION
 
 			DO_OPTION_CMD('z', "list-games")
-				listGames();
-				exit(0);
+				return "list-games";
 			END_OPTION
 
 
@@ -576,6 +531,9 @@
 			usage("Unrecognized option '%s'", argv[i]);
 		}
 	}
+
+
+	return Common::String::emptyString;
 }
 
 

Modified: scummvm/trunk/base/gameDetector.h
===================================================================
--- scummvm/trunk/base/gameDetector.h	2006-04-02 20:49:03 UTC (rev 21568)
+++ scummvm/trunk/base/gameDetector.h	2006-04-02 21:06:49 UTC (rev 21569)
@@ -69,7 +69,7 @@
 public:
 	GameDetector();
 
-	static void parseCommandLine(Common::StringMap &settings, int argc, char **argv);
+	static Common::String parseCommandLine(Common::StringMap &settings, int argc, char **argv);
 	void processSettings(Common::StringMap &settings);
 	bool detectMain();
 

Modified: scummvm/trunk/base/main.cpp
===================================================================
--- scummvm/trunk/base/main.cpp	2006-04-02 20:49:03 UTC (rev 21568)
+++ scummvm/trunk/base/main.cpp	2006-04-02 21:06:49 UTC (rev 21569)
@@ -142,6 +142,49 @@
 #endif
 	;
 
+/** List all supported game IDs, i.e. all games which any loaded plugin supports. */
+void listGames() {
+	const PluginList &plugins = PluginManager::instance().getPlugins();
+
+	printf("Game ID              Full Title                                            \n"
+	       "-------------------- ------------------------------------------------------\n");
+
+	PluginList::const_iterator iter = plugins.begin();
+	for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
+		GameList list = (*iter)->getSupportedGames();
+		for (GameList::iterator v = list.begin(); v != list.end(); ++v) {
+			printf("%-20s %s\n", v->gameid.c_str(), v->description.c_str());
+		}
+	}
+}
+
+/** 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::const_iterator iter = domains.begin();
+	for (iter = domains.begin(); iter != domains.end(); ++iter) {
+		String name(iter->_key);
+		String description(iter->_value.get("description"));
+
+		if (description.empty()) {
+			// FIXME: At this point, we should check for a "gameid" override
+			// to find the proper desc. In fact, the platform probably should
+			// be taken into account, too.
+			String gameid(name);
+			GameDescriptor g = GameDetector::findGame(gameid);
+			if (g.description.size() > 0)
+				description = g.description;
+		}
+
+		printf("%-20s %s\n", name.c_str(), description.c_str());
+	}
+}
+
 static void setupDummyPalette(OSystem &system) {
 	// FIXME - mouse cursors are currently always set via 8 bit data.
 	// Thus for now we need to setup a dummy palette. On the long run, we might
@@ -271,6 +314,7 @@
 extern "C" int scummvm_main(int argc, char *argv[]) {
 #endif
 	Common::String specialDebug;
+	Common::String command;
 	bool running = true;
 
 	// Verify that the backend has been initialized (i.e. g_system has been set).
@@ -279,7 +323,7 @@
 
 	// Parse the command line
 	Common::StringMap settings;
-	GameDetector::parseCommandLine(settings, argc, argv);
+	command = GameDetector::parseCommandLine(settings, argc, argv);
 
 	// Load the config file (possibly overriden via command line):
 	if (settings.contains("config")) {
@@ -303,6 +347,22 @@
 
 	// Load the plugins
 	PluginManager::instance().loadPlugins();
+	
+	
+	// Handle commands passed via the command line (like --list-targets and
+	// --list-games). This must be done after the config file and the plugins
+	// have been loaded.
+	// FIXME: The way are are doing this is rather arbitrary at this time.
+	// E.g. --version and --help are very similar, but are still handled
+	// inside parseCommandLine. This should be unified.
+	if (command == "list-targets") {
+		listTargets();
+		exit(0);
+	} else if (command == "list-games") {
+		listGames();
+		exit(0);
+	}
+	
 
 	// Process the command line settings
 #ifndef _WIN32_WCE


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list