[Scummvm-git-logs] scummvm master -> 577e189a37fb2a1c4504a75c8874c03c9943d326

criezy criezy at scummvm.org
Mon Nov 7 20:31:27 CET 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
577e189a37 BASE: Auto-detect now starts the first game found


Commit: 577e189a37fb2a1c4504a75c8874c03c9943d326
    https://github.com/scummvm/scummvm/commit/577e189a37fb2a1c4504a75c8874c03c9943d326
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2016-11-07T19:29:53Z

Commit Message:
BASE: Auto-detect now starts the first game found

Changed paths:
    README
    base/commandLine.cpp



diff --git a/README b/README
index e674bf0..3c9474f 100644
--- a/README
+++ b/README
@@ -1309,8 +1309,10 @@ arguments -- see the next section.
   -z, --list-games         Display list of supported games and exit
   -t, --list-targets       Display list of configured targets and exit
   --list-saves=TARGET      Display a list of saved games for the game (TARGET) specified
-  --auto-detect            Display a list of games from current or specified directory.
-                           Use --path=PATH before --auto-detect to specify a directory.
+  --auto-detect            Display a list of games from current or specified
+                           directory and start the first one found. Use
+                           --path=PATH before--auto-detect to specify a
+                           directory.
   --console                Enable the console window (default: enabled) (Windows only)
 
   -c, --config=CONFIG      Use alternate configuration file
diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 0a900c4..2d7b9f2 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -69,7 +69,8 @@ static const char HELP_STRING[] =
 	"  -t, --list-targets       Display list of configured targets and exit\n"
 	"  --list-saves=TARGET      Display a list of saved games for the game (TARGET) specified\n"
 	"  --auto-detect            Display a list of games from current or specified directory\n"
-	"                           Use --path=PATH before --auto-detect to specify a directory.\n"
+	"                           and start the first one. Use --path=PATH before --auto-detect\n"
+	"                           to specify a directory.\n"
 #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
 	"  --console                Enable the console window (default:enabled)\n"
 #endif
@@ -777,7 +778,7 @@ static void listAudioDevices() {
 }
 
 /** Display all games in the given directory, or current directory if empty */
-static void autoDetect(Common::String path) {
+static bool autoDetect(Common::String path) {
 	if (path.empty())
 		path = ".";
 	//Current directory
@@ -791,13 +792,18 @@ static void autoDetect(Common::String path) {
 	GameList candidates(EngineMan.detectGames(files));
 	if (candidates.empty()) {
 		printf("ScummVM could not find any game in %s\n", path.c_str());
-	} else {
-		printf("ID                   Description\n");
-		printf("-------------------- ---------------------------------------------------------\n");
-		for (GameList::iterator v = candidates.begin(); v != candidates.end(); ++v) {
-			printf("%-20s %s\n", v->gameid().c_str(), v->description().c_str());
-		}
+		return false;
 	}
+
+	// Print all the candidate found
+	printf("ID                   Description\n");
+	printf("-------------------- ---------------------------------------------------------\n");
+	for (GameList::iterator v = candidates.begin(); v != candidates.end(); ++v) {
+		printf("%-20s %s\n", v->gameid().c_str(), v->description().c_str());
+	}
+	// Set the active domain to the first one to start it.
+	ConfMan.setActiveDomain(candidates.begin()->gameid());
+	return true;
 }
 
 #ifdef DETECTOR_TESTING_HACK
@@ -1026,8 +1032,9 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo
 		printf(HELP_STRING, s_appName);
 		return true;
 	} else if (command == "auto-detect") {
-		autoDetect(settings["path"]);
-		return true;
+		// If auto-detects succeed, we want to return false so that the game is started
+		return !autoDetect(settings["path"]);
+		//return true;
 	}
 #ifdef DETECTOR_TESTING_HACK
 	else if (command == "test-detector") {





More information about the Scummvm-git-logs mailing list