added getBool and set(bool) to the Config class; made GameDetector take advantage of these; also, -A/-F/-N will turn OFF amiga/fullscreen/nosubtitles modes (so you can override the config file for these settings if desired)
svn-id: r4771
This commit is contained in:
parent
d354eaaf42
commit
11757715ab
3 changed files with 60 additions and 91 deletions
|
@ -234,20 +234,19 @@ const char *Config::get(const char *key, const char *d) const
|
|||
|
||||
const int Config::getInt(const char *key, int def, const char *d) const
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!d)
|
||||
d = domain;
|
||||
|
||||
for (i = 0; i < ndomains; i++) {
|
||||
if (hash[i]->is_domain(d)) {
|
||||
const char *val = hash[i]->get(key);
|
||||
if (val)
|
||||
return atoi(val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
const char *value = get(key, d);
|
||||
|
||||
if (value)
|
||||
return atoi(value);
|
||||
return def;
|
||||
}
|
||||
|
||||
const bool Config::getBool(const char *key, bool def, const char *d) const
|
||||
{
|
||||
const char *value = get(key, d);
|
||||
|
||||
if (value)
|
||||
return !scumm_stricmp(value, "true");
|
||||
return def;
|
||||
}
|
||||
|
||||
|
@ -273,25 +272,15 @@ const char *Config::set(const char *key, const char *value, const char *d)
|
|||
|
||||
const char *Config::set(const char *key, int value_i, const char *d)
|
||||
{
|
||||
int i;
|
||||
char value[MAXLINELEN];
|
||||
|
||||
sprintf(value, "%i", value_i);
|
||||
return set(key, value, d);
|
||||
}
|
||||
|
||||
if (!d)
|
||||
d = domain;
|
||||
|
||||
for (i = 0; i < ndomains; i++) {
|
||||
if (hash[i]->is_domain(d)) {
|
||||
return hash[i]->set(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
ndomains++;
|
||||
hash = (hashconfig **)realloc(hash, ndomains * sizeof(hashconfig *));
|
||||
hash[ndomains - 1] = new hashconfig (d);
|
||||
|
||||
return hash[ndomains - 1]->set(key, value);
|
||||
const char *Config::set(const char *key, bool value_b, const char *d)
|
||||
{
|
||||
const char *value = value_b ? "true" : "false";
|
||||
return set(key, value, d);
|
||||
}
|
||||
|
||||
void Config::set_domain(const char *d)
|
||||
|
|
|
@ -31,8 +31,12 @@ public:
|
|||
~Config ();
|
||||
const char *get(const char *key, const char *dom = 0) const;
|
||||
const int getInt(const char *key, int def = 0, const char *dom = 0) const;
|
||||
const bool getBool(const char *key, bool def = false, const char *dom = 0) const;
|
||||
|
||||
const char *set(const char *key, const char *value, const char *dom = 0);
|
||||
const char *set(const char *key, int value, const char *dom = 0);
|
||||
const char *set(const char *key, bool value, const char *dom = 0);
|
||||
|
||||
void set_domain(const char *);
|
||||
void flush() const;
|
||||
void rename_domain(const char *);
|
||||
|
|
100
gameDetector.cpp
100
gameDetector.cpp
|
@ -71,16 +71,11 @@ void GameDetector::updateconfig()
|
|||
{
|
||||
const char * val;
|
||||
|
||||
if ((val = scummcfg->get("amiga")))
|
||||
if (!scumm_stricmp(val, "true"))
|
||||
_amiga = true;
|
||||
else
|
||||
_amiga = false;
|
||||
if ((val = scummcfg->get("save_slot")))
|
||||
_save_slot = atoi(val);
|
||||
_amiga = scummcfg->getBool("amiga", _amiga);
|
||||
|
||||
if ((val = scummcfg->get("cdrom")))
|
||||
_cdrom = atoi(val);
|
||||
_save_slot = scummcfg->getInt("save_slot", _save_slot);
|
||||
|
||||
_cdrom = scummcfg->getInt("cdrom", _cdrom);
|
||||
|
||||
if ((val = scummcfg->get("music_driver")))
|
||||
if (!parseMusicDriver(val)) {
|
||||
|
@ -89,11 +84,7 @@ void GameDetector::updateconfig()
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
if ((val = scummcfg->get("fullscreen", "scummvm")))
|
||||
if (!scumm_stricmp(val, "true"))
|
||||
_fullScreen = true;
|
||||
else
|
||||
_fullScreen = false;
|
||||
_fullScreen = scummcfg->getBool("fullscreen", _fullScreen);
|
||||
|
||||
if ((val = scummcfg->get("gfx_mode")))
|
||||
if ((_gfx_mode = parseGraphicsMode(val)) == -1) {
|
||||
|
@ -102,35 +93,29 @@ void GameDetector::updateconfig()
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
if ((val = scummcfg->get("music_volume")))
|
||||
_music_volume = atoi(val);
|
||||
_music_volume = scummcfg->getInt("music_volume", _music_volume);
|
||||
|
||||
if ((val = scummcfg->get("nosubtitles")))
|
||||
if (!scumm_stricmp(val, "true"))
|
||||
_noSubtitles = true;
|
||||
else
|
||||
_noSubtitles = false;
|
||||
_noSubtitles = scummcfg->getBool("nosubtitles", _noSubtitles);
|
||||
|
||||
if ((val = scummcfg->get("path")))
|
||||
_gameDataPath = strdup(val);
|
||||
|
||||
if ((val = scummcfg->get("sfx_volume")))
|
||||
_sfx_volume = atoi(val);
|
||||
_sfx_volume = scummcfg->getInt("sfx_volume", _sfx_volume);
|
||||
|
||||
// We use strtol for the tempo to allow it to be specified in hex.
|
||||
if ((val = scummcfg->get("tempo")))
|
||||
_gameTempo = strtol(val, NULL, 0);
|
||||
|
||||
if ((val = scummcfg->get("talkspeed")))
|
||||
_talkSpeed = atoi(val);
|
||||
_talkSpeed = scummcfg->getInt("talkspeed", _talkSpeed);
|
||||
}
|
||||
|
||||
void GameDetector::parseCommandLine(int argc, char **argv)
|
||||
{
|
||||
#if !defined(MACOS_CARBON)
|
||||
int i;
|
||||
char *s;
|
||||
char *current_option = NULL;
|
||||
char *option = NULL;
|
||||
char c;
|
||||
_save_slot = -1;
|
||||
|
||||
// check for arguments
|
||||
|
@ -146,11 +131,12 @@ void GameDetector::parseCommandLine(int argc, char **argv)
|
|||
|
||||
if (s[0] == '-') {
|
||||
s++;
|
||||
switch (tolower(*s++)) {
|
||||
c = *s++;
|
||||
switch (tolower(c)) {
|
||||
case 'a':
|
||||
CHECK_OPTION();
|
||||
_amiga = true;
|
||||
scummcfg->set("amiga", "true");
|
||||
_amiga = (c == 'a');
|
||||
scummcfg->set("amiga", _amiga);
|
||||
break;
|
||||
case 'b':
|
||||
HANDLE_OPTION();
|
||||
|
@ -176,8 +162,8 @@ void GameDetector::parseCommandLine(int argc, char **argv)
|
|||
break;
|
||||
case 'f':
|
||||
CHECK_OPTION();
|
||||
_fullScreen = true;
|
||||
scummcfg->set("fullscreen", "true", "scummvm");
|
||||
_fullScreen = (c == 'f');
|
||||
scummcfg->set("fullscreen", _fullScreen, "scummvm");
|
||||
break;
|
||||
case 'g':
|
||||
HANDLE_OPTION();
|
||||
|
@ -203,8 +189,8 @@ void GameDetector::parseCommandLine(int argc, char **argv)
|
|||
break;
|
||||
case 'n':
|
||||
CHECK_OPTION();
|
||||
_noSubtitles = true;
|
||||
scummcfg->set("nosubtitles", "true");
|
||||
_noSubtitles = (c == 'n');
|
||||
scummcfg->set("nosubtitles", _noSubtitles);
|
||||
break;
|
||||
case 'p':
|
||||
HANDLE_OPTION();
|
||||
|
@ -280,14 +266,6 @@ void GameDetector::parseCommandLine(int argc, char **argv)
|
|||
ShowHelpAndExit:
|
||||
printf(USAGE_STRING);
|
||||
exit(1);
|
||||
|
||||
#else
|
||||
_midi_driver = MD_QTMUSIC;
|
||||
_exe_name = *argv;
|
||||
_gameDataPath = (char *)malloc(strlen(_exe_name) + 3);
|
||||
sprintf(_gameDataPath, ":%s:", _exe_name);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
int GameDetector::parseGraphicsMode(const char *s) {
|
||||
|
@ -377,20 +355,16 @@ static const VersionSettings version_settings[] = {
|
|||
// {"indy3", "Indiana Jones and the Last Crusade", GID_INDY3, 2, 0, 0,},
|
||||
|
||||
/* Scumm Version 3 */
|
||||
{"indy3", "Indiana Jones and the Last Crusade (256)", GID_INDY3_256, 3, 0,
|
||||
22,
|
||||
GF_SMALL_HEADER | GF_USE_KEY | GF_SMALL_NAMES | GF_OLD256 |
|
||||
GF_NO_SCALLING},
|
||||
{"zak256", "Zak McKracken and the Alien Mindbenders (256)", GID_ZAK256, 3,
|
||||
0, 0,
|
||||
GF_SMALL_HEADER | GF_USE_KEY | GF_SMALL_NAMES | GF_OLD256 | GF_AUDIOTRACKS
|
||||
| GF_NO_SCALLING},
|
||||
{"indy3", "Indiana Jones and the Last Crusade (256)", GID_INDY3_256, 3, 0, 22,
|
||||
GF_SMALL_HEADER | GF_USE_KEY | GF_SMALL_NAMES | GF_OLD256 | GF_NO_SCALLING},
|
||||
{"zak256", "Zak McKracken and the Alien Mindbenders (256)", GID_ZAK256, 3, 0, 0,
|
||||
GF_SMALL_HEADER | GF_USE_KEY | GF_SMALL_NAMES | GF_OLD256 | GF_AUDIOTRACKS | GF_NO_SCALLING},
|
||||
{"loom", "Loom", GID_LOOM, 3, 5, 40,
|
||||
GF_SMALL_HEADER | GF_USE_KEY | GF_SMALL_NAMES | GF_OLD_BUNDLE | GF_16COLOR
|
||||
| GF_NO_SCALLING},
|
||||
GF_SMALL_HEADER | GF_USE_KEY | GF_SMALL_NAMES | GF_OLD_BUNDLE | GF_16COLOR | GF_NO_SCALLING},
|
||||
|
||||
/* Scumm Version 4 */
|
||||
{"monkeyEGA", "Monkey Island 1 (EGA)", GID_MONKEY_EGA, 4, 0, 67, GF_SMALL_HEADER | GF_USE_KEY | GF_16COLOR}, // EGA version
|
||||
{"monkeyEGA", "Monkey Island 1 (EGA)", GID_MONKEY_EGA, 4, 0, 67,
|
||||
GF_SMALL_HEADER | GF_USE_KEY | GF_16COLOR}, // EGA version
|
||||
|
||||
/* Scumm version 5 */
|
||||
{"monkeyVGA", "Monkey Island 1 (256 color Floppy version)", GID_MONKEY_VGA, 5, 0, 16,
|
||||
|
@ -405,10 +379,10 @@ static const VersionSettings version_settings[] = {
|
|||
GF_USE_KEY | GF_ADLIB_DEFAULT},
|
||||
{"atlantis", "Indiana Jones and the Fate of Atlantis", GID_INDY4, 5, 5, 0,
|
||||
GF_USE_KEY | GF_ADLIB_DEFAULT},
|
||||
{"playfate", "Indiana Jones and the Fate of Atlantis (Demo)", GID_INDY4,
|
||||
5, 5, 0, GF_USE_KEY | GF_ADLIB_DEFAULT},
|
||||
{"fate", "Indiana Jones and the Fate of Atlantis (Demo)", GID_INDY4,
|
||||
5, 5, 0, GF_USE_KEY | GF_ADLIB_DEFAULT},
|
||||
{"playfate", "Indiana Jones and the Fate of Atlantis (Demo)", GID_INDY4, 5, 5, 0,
|
||||
GF_USE_KEY | GF_ADLIB_DEFAULT},
|
||||
{"fate", "Indiana Jones and the Fate of Atlantis (Demo)", GID_INDY4, 5, 5, 0,
|
||||
GF_USE_KEY | GF_ADLIB_DEFAULT},
|
||||
|
||||
/* Scumm Version 6 */
|
||||
{"tentacle", "Day Of The Tentacle", GID_TENTACLE, 6, 4, 2,
|
||||
|
@ -418,12 +392,12 @@ static const VersionSettings version_settings[] = {
|
|||
{"samnmax", "Sam & Max", GID_SAMNMAX, 6, 4, 2,
|
||||
GF_NEW_OPCODES | GF_AFTER_V6 | GF_USE_KEY | GF_DRAWOBJ_OTHER_ORDER},
|
||||
{"samdemo", "Sam & Max (Demo)", GID_SAMNMAX, 6, 3, 0,
|
||||
GF_NEW_OPCODES | GF_AFTER_V6 | GF_USE_KEY | GF_DRAWOBJ_OTHER_ORDER | GF_ADLIB_DEFAULT},
|
||||
GF_NEW_OPCODES | GF_AFTER_V6 | GF_USE_KEY | GF_DRAWOBJ_OTHER_ORDER | GF_ADLIB_DEFAULT},
|
||||
{"snmdemo", "Sam & Max (Demo)", GID_SAMNMAX, 6, 3, 0,
|
||||
GF_NEW_OPCODES | GF_AFTER_V6 | GF_USE_KEY | GF_DRAWOBJ_OTHER_ORDER | GF_ADLIB_DEFAULT},
|
||||
GF_NEW_OPCODES | GF_AFTER_V6 | GF_USE_KEY | GF_DRAWOBJ_OTHER_ORDER | GF_ADLIB_DEFAULT},
|
||||
|
||||
{"puttdemo", "Putt Putt joins the parade (demo)", GID_SAMNMAX, 6, 3, 0,
|
||||
GF_NEW_OPCODES | GF_AFTER_V6 | GF_USE_KEY | GF_ADLIB_DEFAULT | GF_HUMONGOUS},
|
||||
GF_NEW_OPCODES | GF_AFTER_V6 | GF_USE_KEY | GF_ADLIB_DEFAULT | GF_HUMONGOUS},
|
||||
{"moondemo", "Putt Putt goes to the moon (demo)", GID_SAMNMAX, 6, 3, 0,
|
||||
GF_NEW_OPCODES | GF_AFTER_V6 | GF_USE_KEY | GF_ADLIB_DEFAULT | GF_HUMONGOUS},
|
||||
|
||||
|
@ -437,12 +411,14 @@ static const VersionSettings version_settings[] = {
|
|||
|
||||
/* Simon the Sorcerer 1 & 2 (not SCUMM games) */
|
||||
{"simon1dos", "Simon the Sorcerer 1 for DOS", GID_SIMON_FIRST+0, 99, 99, 99, 0},
|
||||
{"simon2dos", "Simon the Sorcerer 2 for Dos", GID_SIMON_FIRST+1, 99, 99, 99, 0},
|
||||
{"simon2dos", "Simon the Sorcerer 2 for DOS", GID_SIMON_FIRST+1, 99, 99, 99, 0},
|
||||
{"simon1win", "Simon the Sorcerer 1 for Windows", GID_SIMON_FIRST+2, 99, 99, 99, 0},
|
||||
{"simon2win", "Simon the Sorcerer 2 for Windows", GID_SIMON_FIRST+3, 99, 99, 99, 0},
|
||||
|
||||
/* Scumm Version 8 */
|
||||
{"comi", "The Curse of Monkey Island", GID_CMI, 8, 1, 0, GF_NEW_OPCODES|GF_AFTER_V6|GF_AFTER_V7|GF_AFTER_V8},
|
||||
{"comi", "The Curse of Monkey Island", GID_CMI, 8, 1, 0,
|
||||
GF_NEW_OPCODES | GF_AFTER_V6 | GF_AFTER_V7 | GF_AFTER_V8},
|
||||
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
@ -643,7 +619,7 @@ MidiDriver *GameDetector::createMidi() {
|
|||
#if defined(__APPLE__) || defined(macintosh)
|
||||
case MD_QTMUSIC: return MidiDriver_QT_create();
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
#if defined(MACOSX)
|
||||
case MD_COREAUDIO: return MidiDriver_CORE_create();
|
||||
#endif
|
||||
#if defined(UNIX) && defined(USE_ALSA)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue