From 598407a42516fde44df8d3e5f9fac2f1800b1983 Mon Sep 17 00:00:00 2001 From: iskrich Date: Sat, 19 Mar 2016 17:23:44 +0300 Subject: 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. --- base/commandLine.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'base') 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") { -- cgit v1.2.3