Add -c/--config option to specific alternate configuration file. Sorry Max, but it's damn useful for coverdiscs :)
svn-id: r12758
This commit is contained in:
parent
a2039576fb
commit
9b97d851fe
4 changed files with 40 additions and 1 deletions
|
@ -48,6 +48,7 @@ static const char USAGE_STRING[] =
|
||||||
" -z, --list-games Display list of supported games and exit\n"
|
" -z, --list-games Display list of supported games and exit\n"
|
||||||
" -t, --list-targets Display list of configured targets and exit\n"
|
" -t, --list-targets Display list of configured targets and exit\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
" -c, --config=CONFIG Use alternate configuration file\n"
|
||||||
" -p, --path=PATH Path to where the game is installed\n"
|
" -p, --path=PATH Path to where the game is installed\n"
|
||||||
" -x, --save-slot[=NUM] Save game slot to load (default: autosave)\n"
|
" -x, --save-slot[=NUM] Save game slot to load (default: autosave)\n"
|
||||||
" -f, --fullscreen Force full-screen mode\n"
|
" -f, --fullscreen Force full-screen mode\n"
|
||||||
|
@ -284,6 +285,10 @@ void GameDetector::parseCommandLine(int argc, char **argv) {
|
||||||
cmdValue = (shortCmdLower == s[1]);
|
cmdValue = (shortCmdLower == s[1]);
|
||||||
s += 2;
|
s += 2;
|
||||||
|
|
||||||
|
DO_OPTION('c', "config")
|
||||||
|
// Dummy
|
||||||
|
END_OPTION
|
||||||
|
|
||||||
DO_OPTION('b', "boot-param")
|
DO_OPTION('b', "boot-param")
|
||||||
ConfMan.set("boot_param", (int)strtol(option, 0, 10), kTransientDomain);
|
ConfMan.set("boot_param", (int)strtol(option, 0, 10), kTransientDomain);
|
||||||
END_OPTION
|
END_OPTION
|
||||||
|
|
|
@ -245,6 +245,7 @@ int main(int argc, char *argv[]) {
|
||||||
extern "C" int scummvm_main(GameDetector &detector, int argc, char *argv[]) {
|
extern "C" int scummvm_main(GameDetector &detector, int argc, char *argv[]) {
|
||||||
#endif
|
#endif
|
||||||
OSystem::Property prop;
|
OSystem::Property prop;
|
||||||
|
char *cfgFilename = NULL, *s=argv[1];
|
||||||
|
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
/* On Unix, do a quick endian / alignement check before starting */
|
/* On Unix, do a quick endian / alignement check before starting */
|
||||||
|
@ -286,6 +287,28 @@ extern "C" int scummvm_main(GameDetector &detector, int argc, char *argv[]) {
|
||||||
|
|
||||||
#endif //defined(WIN32) && defined(USE_CONSOLE)
|
#endif //defined(WIN32) && defined(USE_CONSOLE)
|
||||||
|
|
||||||
|
|
||||||
|
// Quick preparse of command-line, looking for alt configfile path
|
||||||
|
for (int i = argc - 1; i >= 1; i--) {
|
||||||
|
s = argv[i];
|
||||||
|
bool shortOpt = (s[0] == '-' && tolower(s[1]) == 'c');
|
||||||
|
bool longOpt = (s[0] == '-' && s[1] == '-' && s[2] == 'c' && s[3] == 'o' \
|
||||||
|
&& s[4] == 'n' && s[5] == 'f' && s[6] == 'i' && s[7] == 'g');
|
||||||
|
|
||||||
|
if (shortOpt || longOpt) {
|
||||||
|
if (longOpt) s+=9;
|
||||||
|
if (shortOpt) s+=2;
|
||||||
|
|
||||||
|
if (*s == '\0')
|
||||||
|
break;
|
||||||
|
|
||||||
|
cfgFilename = s;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cfgFilename != NULL)
|
||||||
|
ConfMan.switchFile(cfgFilename);
|
||||||
|
|
||||||
// Update the config file
|
// Update the config file
|
||||||
ConfMan.set("versioninfo", gScummVMVersion, Common::ConfigManager::kApplicationDomain);
|
ConfMan.set("versioninfo", gScummVMVersion, Common::ConfigManager::kApplicationDomain);
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,14 @@ ConfigManager::ConfigManager() {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
switchFile(configFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigManager::switchFile(const String &filename) {
|
||||||
|
_globalDomains.clear();
|
||||||
|
_gameDomains.clear();
|
||||||
|
_transientDomain.clear();
|
||||||
|
|
||||||
// Ensure the global domain(s) are setup.
|
// Ensure the global domain(s) are setup.
|
||||||
_globalDomains.addKey(kApplicationDomain);
|
_globalDomains.addKey(kApplicationDomain);
|
||||||
#ifdef _WIN32_WCE
|
#ifdef _WIN32_WCE
|
||||||
|
@ -94,8 +102,9 @@ ConfigManager::ConfigManager() {
|
||||||
_globalDomains.addKey("smartfon-keys");
|
_globalDomains.addKey("smartfon-keys");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_filename = configFile;
|
_filename = filename;
|
||||||
loadFile(_filename);
|
loadFile(_filename);
|
||||||
|
printf("Switched to configuration %s\n", _filename.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigManager::loadFile(const String &filename) {
|
void ConfigManager::loadFile(const String &filename) {
|
||||||
|
|
|
@ -61,6 +61,8 @@ public:
|
||||||
/** The transient (pseudo) domain. */
|
/** The transient (pseudo) domain. */
|
||||||
static const String kTransientDomain;
|
static const String kTransientDomain;
|
||||||
|
|
||||||
|
void switchFile(const String &filename);
|
||||||
|
|
||||||
bool hasKey(const String &key) const;
|
bool hasKey(const String &key) const;
|
||||||
bool hasKey(const String &key, const String &dom) const;
|
bool hasKey(const String &key, const String &dom) const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue