diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/commandLine.cpp | 38 | ||||
-rw-r--r-- | base/main.cpp | 4 |
2 files changed, 42 insertions, 0 deletions
diff --git a/base/commandLine.cpp b/base/commandLine.cpp index 558c147b96..2d7b9f2d9f 100644 --- a/base/commandLine.cpp +++ b/base/commandLine.cpp @@ -68,6 +68,9 @@ 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 or specified 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 @@ -402,6 +405,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 +777,34 @@ static void listAudioDevices() { } } +/** Display all games in the given directory, or current directory if empty */ +static bool autoDetect(Common::String path) { + if (path.empty()) + path = "."; + //Current directory + Common::FSNode dir(path); + + Common::FSList files; + + //Collect all files from directory + dir.getChildren(files, Common::FSNode::kListAll); + + GameList candidates(EngineMan.detectGames(files)); + if (candidates.empty()) { + printf("ScummVM could not find any game in %s\n", path.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 static void runDetectorTest() { @@ -997,6 +1031,10 @@ 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") { + // 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") { diff --git a/base/main.cpp b/base/main.cpp index 42f5910b3b..c52888a827 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -51,6 +51,7 @@ #include "common/textconsole.h" #include "common/tokenizer.h" #include "common/translation.h" +#include "common/osd_message_queue.h" #include "gui/gui-manager.h" #include "gui/error.h" @@ -477,6 +478,8 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { g_eventRec.RegisterEventSource(); #endif + Common::OSDMessageQueue::instance().registerEventSource(); + // Now as the event manager is created, setup the keymapper setupKeymapper(system); @@ -615,6 +618,7 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { GUI::GuiManager::destroy(); Common::ConfigManager::destroy(); Common::DebugManager::destroy(); + Common::OSDMessageQueue::destroy(); #ifdef ENABLE_EVENTRECORDER GUI::EventRecorder::destroy(); #endif |