diff options
author | Marcus Comstedt | 2010-07-29 20:37:56 +0000 |
---|---|---|
committer | Marcus Comstedt | 2010-07-29 20:37:56 +0000 |
commit | 630127bc077e56c619c816a89e1d577c38b5eafb (patch) | |
tree | 1bcb1aecc3e89d2cdc4a533abc4171f06513c334 | |
parent | e9234b61d671141761ea77e88302180d9d55b2f9 (diff) | |
download | scummvm-rg350-630127bc077e56c619c816a89e1d577c38b5eafb.tar.gz scummvm-rg350-630127bc077e56c619c816a89e1d577c38b5eafb.tar.bz2 scummvm-rg350-630127bc077e56c619c816a89e1d577c38b5eafb.zip |
DC: Let scummvm.ini override autodetect of games
If a game CD has a scummvm.ini file with at least one game domain in
it, the normal autodetection is now bypassed and a menu of only the
games in the .ini file is presented instead. The descriptions of the
games are taken from the .ini file, but icons are still scanned for
in the old fashion.
Note that previously ScummVM would read global options from the
scummvm.ini file on the boot disc (if present), but now global options
are instead taken from the scummvm.ini on the game disc (in case of
a disc swap).
svn-id: r51480
-rw-r--r-- | backends/platform/dc/selector.cpp | 98 |
1 files changed, 67 insertions, 31 deletions
diff --git a/backends/platform/dc/selector.cpp b/backends/platform/dc/selector.cpp index 0d8e0a0188..0d9b931d2c 100644 --- a/backends/platform/dc/selector.cpp +++ b/backends/platform/dc/selector.cpp @@ -30,6 +30,7 @@ #include <base/plugins.h> #include <common/fs.h> #include <common/events.h> +#include <common/config-manager.h> #include "dc.h" #include "icon.h" #include "label.h" @@ -200,12 +201,43 @@ static bool uniqueGame(const char *base, const char *dir, return true; } -static int findGames(Game *games, int max) +static int findGames(Game *games, int max, bool use_ini) { Dir *dirs = new Dir[MAX_DIR]; - int curr_game = 0, curr_dir = 0, num_dirs = 1; - dirs[0].node = Common::FSNode(""); - while (curr_game < max && curr_dir < num_dirs) { + int curr_game = 0, curr_dir = 0, num_dirs = 0; + + if (use_ini) { + ConfMan.loadDefaultConfigFile(); + Common::ConfigManager::DomainMap &game_domains = ConfMan.getGameDomains(); + for(Common::ConfigManager::DomainMap::const_iterator i = + game_domains.begin(); curr_game < max && i != game_domains.end(); i++) { + Common::String path = (*i)._value["path"]; + if (path.size() && path.lastChar() != '/') + path += "/"; + int j; + for (j=0; j<num_dirs; j++) + if (path.equals(dirs[j].node.getPath())) + break; + if (j >= num_dirs) { + if (num_dirs >= MAX_DIR) + continue; + dirs[j = num_dirs++].node = Common::FSNode(path); + } + if (curr_game < max) { + strcpy(games[curr_game].filename_base, (*i)._key.c_str()); + strncpy(games[curr_game].dir, dirs[j].node.getPath().c_str(), 256); + games[curr_game].dir[255] = '\0'; + games[curr_game].language = Common::UNK_LANG; + games[curr_game].platform = Common::kPlatformUnknown; + strcpy(games[curr_game].text, (*i)._value["description"].c_str()); + curr_game++; + } + } + } else { + dirs[num_dirs++].node = Common::FSNode(""); + } + + while ((curr_game < max || use_ini) && curr_dir < num_dirs) { strncpy(dirs[curr_dir].name, dirs[curr_dir].node.getPath().c_str(), 252); dirs[curr_dir].name[251] = '\0'; dirs[curr_dir].deficon[0] = '\0'; @@ -214,44 +246,46 @@ static int findGames(Game *games, int max) for (Common::FSList::const_iterator entry = fslist.begin(); entry != fslist.end(); ++entry) { if (entry->isDirectory()) { - if (num_dirs < MAX_DIR && strcasecmp(entry->getDisplayName().c_str(), - "install")) { + if (!use_ini && num_dirs < MAX_DIR && + strcasecmp(entry->getDisplayName().c_str(), "install")) { dirs[num_dirs].node = *entry; num_dirs++; } } else if (isIcon(*entry)) strcpy(dirs[curr_dir-1].deficon, entry->getDisplayName().c_str()); - else + else if(!use_ini) files.push_back(*entry); } - GameList candidates = EngineMan.detectGames(files); - - for (GameList::const_iterator ge = candidates.begin(); - ge != candidates.end(); ++ge) - if (curr_game < max) { - strcpy(games[curr_game].filename_base, ge->gameid().c_str()); - strcpy(games[curr_game].dir, dirs[curr_dir-1].name); - games[curr_game].language = ge->language(); - games[curr_game].platform = ge->platform(); - if (uniqueGame(games[curr_game].filename_base, - games[curr_game].dir, - games[curr_game].language, - games[curr_game].platform, games, curr_game)) { - - strcpy(games[curr_game].text, ge->description().c_str()); + if (!use_ini) { + GameList candidates = EngineMan.detectGames(files); + + for (GameList::const_iterator ge = candidates.begin(); + ge != candidates.end(); ++ge) + if (curr_game < max) { + strcpy(games[curr_game].filename_base, ge->gameid().c_str()); + strcpy(games[curr_game].dir, dirs[curr_dir-1].name); + games[curr_game].language = ge->language(); + games[curr_game].platform = ge->platform(); + if (uniqueGame(games[curr_game].filename_base, + games[curr_game].dir, + games[curr_game].language, + games[curr_game].platform, games, curr_game)) { + + strcpy(games[curr_game].text, ge->description().c_str()); #if 0 - printf("Registered game <%s> (l:%d p:%d) in <%s> <%s> because of <%s> <*>\n", - games[curr_game].text, - (int)games[curr_game].language, - (int)games[curr_game].platform, - games[curr_game].dir, games[curr_game].filename_base, - dirs[curr_dir-1].name); + printf("Registered game <%s> (l:%d p:%d) in <%s> <%s> because of <%s> <*>\n", + games[curr_game].text, + (int)games[curr_game].language, + (int)games[curr_game].platform, + games[curr_game].dir, games[curr_game].filename_base, + dirs[curr_dir-1].name); #endif - curr_game++; + curr_game++; + } } - } + } } for (int i=0; i<curr_game; i++) @@ -426,7 +460,9 @@ bool selectGame(char *&ret, char *&dir_ret, Common::Language &lang_ret, Common:: void *mark = ta_txmark(); for (;;) { - num_games = findGames(games, MAX_GAMES); + num_games = findGames(games, MAX_GAMES, true); + if (!num_games) + num_games = findGames(games, MAX_GAMES, false); for (int i=0; i<num_games; i++) { games[i].icon.create_texture(); |