diff options
author | iskrich | 2016-03-19 17:23:44 +0300 |
---|---|---|
committer | Thierry Crozat | 2016-10-29 17:56:47 +0100 |
commit | 598407a42516fde44df8d3e5f9fac2f1800b1983 (patch) | |
tree | 9b76af89a526155fb7d3d66656de7b5d23d9dc21 /base | |
parent | 9e54089fe74940cf52bceefddb7e92928a4dcf28 (diff) | |
download | scummvm-rg350-598407a42516fde44df8d3e5f9fac2f1800b1983.tar.gz scummvm-rg350-598407a42516fde44df8d3e5f9fac2f1800b1983.tar.bz2 scummvm-rg350-598407a42516fde44df8d3e5f9fac2f1800b1983.zip |
BASE: Add --auto-detect command
Allows to display games in the current directory that are compatible with ScummVM.
This option enables the user to find games in the directory from which ScummVM was launched. In terminal it looks like:
--------------------------------------------------------------------------------------
$ scummvm --auto-detect
ID Description
-------------------- ---------------------------------------------------------
drascula Drascula: The Vampire Strikes Back (DOS/English)
queen Flight of the Amazon Queen (Talkie/DOS/English)
--------------------------------------------------------------------------------------
The current directory is defined as dir(".") then using EngineMan.detectGames to recognise games.
Diffstat (limited to 'base')
-rw-r--r-- | base/commandLine.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/base/commandLine.cpp b/base/commandLine.cpp index 558c147b96..57a5893db0 100644 --- a/base/commandLine.cpp +++ b/base/commandLine.cpp @@ -68,6 +68,7 @@ static const char HELP_STRING[] = " -z, --list-games Display list of supported games and exit\n" " -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 directory\n" #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) " --console Enable the console window (default:enabled)\n" #endif @@ -402,6 +403,9 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha DO_COMMAND('z', "list-games") END_COMMAND + DO_LONG_COMMAND("auto-detect") + END_COMMAND + #ifdef DETECTOR_TESTING_HACK // HACK FIXME TODO: This command is intentionally *not* documented! DO_LONG_COMMAND("test-detector") @@ -771,6 +775,24 @@ static void listAudioDevices() { } } +/** Display all games in current directory */ +static void autoDetect(){ + //Current directory + Common::FSNode dir("."); + Common::FSList files; + //Collect all files from directory + dir.getChildren(files, Common::FSNode::kListAll); + GameList candidates(EngineMan.detectGames(files)); + if (candidates.empty()) { + printf("%s\n","ScummVM could not find any game in the current directory" ); + } 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()); + } + } +} #ifdef DETECTOR_TESTING_HACK static void runDetectorTest() { @@ -997,6 +1019,9 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo } else if (command == "help") { printf(HELP_STRING, s_appName); return true; + } else if (command == "auto-detect"){ + autoDetect(); + return true; } #ifdef DETECTOR_TESTING_HACK else if (command == "test-detector") { |