2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2002-03-25 08:51:34 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-03-25 08:51:34 +00:00
|
|
|
*
|
2006-02-11 09:53:21 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2002-03-25 08:51:34 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-05-13 09:30:23 +00:00
|
|
|
#include "engines/metaengine.h"
|
2006-05-09 14:16:43 +00:00
|
|
|
#include "base/commandLine.h"
|
2003-09-17 22:41:01 +00:00
|
|
|
#include "base/plugins.h"
|
2004-02-09 01:27:27 +00:00
|
|
|
#include "base/version.h"
|
2003-10-02 22:52:57 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
#include "common/config-manager.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "common/system.h"
|
2007-06-16 17:20:46 +00:00
|
|
|
#include "common/fs.h"
|
2003-10-02 22:52:57 +00:00
|
|
|
|
2002-04-19 11:12:27 +00:00
|
|
|
#include "sound/mididrv.h"
|
|
|
|
|
2009-01-02 21:24:13 +00:00
|
|
|
#include "gui/ThemeEngine.h"
|
2009-01-02 20:21:21 +00:00
|
|
|
|
2006-05-04 23:57:49 +00:00
|
|
|
#define DETECTOR_TESTING_HACK
|
2009-06-07 12:47:10 +00:00
|
|
|
#define UPGRADE_ALL_TARGETS_HACK
|
2006-05-04 23:57:49 +00:00
|
|
|
|
2006-05-04 23:37:50 +00:00
|
|
|
namespace Base {
|
|
|
|
|
2008-11-13 12:45:35 +00:00
|
|
|
#ifndef DISABLE_COMMAND_LINE
|
|
|
|
|
2006-04-02 17:51:04 +00:00
|
|
|
static const char USAGE_STRING[] =
|
|
|
|
"%s: %s\n"
|
|
|
|
"Usage: %s [OPTIONS]... [GAME]\n"
|
|
|
|
"\n"
|
|
|
|
"Try '%s --help' for more options.\n"
|
|
|
|
;
|
|
|
|
|
2003-11-07 02:31:44 +00:00
|
|
|
// DONT FIXME: DO NOT ORDER ALPHABETICALLY, THIS IS ORDERED BY IMPORTANCE/CATEGORY! :)
|
2006-04-13 02:39:59 +00:00
|
|
|
#if defined(PALMOS_MODE) || defined(__SYMBIAN32__) || defined(__GP32__)
|
2006-04-02 17:51:04 +00:00
|
|
|
static const char HELP_STRING[] = "NoUsageString"; // save more data segment space
|
2003-04-30 12:43:56 +00:00
|
|
|
#else
|
2006-04-02 17:51:04 +00:00
|
|
|
static const char HELP_STRING[] =
|
2003-08-04 12:42:40 +00:00
|
|
|
"ScummVM - Graphical Adventure Game Interpreter\n"
|
2006-04-02 17:51:04 +00:00
|
|
|
"Usage: %s [OPTIONS]... [GAME]\n"
|
2003-10-26 13:33:49 +00:00
|
|
|
" -v, --version Display ScummVM version information and exit\n"
|
|
|
|
" -h, --help Display a brief help text 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"
|
2008-08-16 02:57:30 +00:00
|
|
|
" --list-saves=TARGET Display a list of savegames for the game (TARGET) specified\n"
|
2002-12-28 12:20:55 +00:00
|
|
|
"\n"
|
2004-02-07 04:53:59 +00:00
|
|
|
" -c, --config=CONFIG Use alternate configuration file\n"
|
2003-10-26 13:33:49 +00:00
|
|
|
" -p, --path=PATH Path to where the game is installed\n"
|
|
|
|
" -x, --save-slot[=NUM] Save game slot to load (default: autosave)\n"
|
|
|
|
" -f, --fullscreen Force full-screen mode\n"
|
|
|
|
" -F, --no-fullscreen Force windowed mode\n"
|
2007-05-26 12:01:33 +00:00
|
|
|
" -g, --gfx-mode=MODE Select graphics scaler (1x,2x,3x,2xsai,super2xsai,\n"
|
|
|
|
" supereagle,advmame2x,advmame3x,hq2x,hq3x,tv2x,\n"
|
|
|
|
" dotmatrix)\n"
|
2009-01-02 20:21:21 +00:00
|
|
|
" --gui-theme=THEME Select GUI theme\n"
|
2006-06-14 19:32:26 +00:00
|
|
|
" --themepath=PATH Path to where GUI themes are stored\n"
|
2009-01-02 20:36:51 +00:00
|
|
|
" --list-themes Display list of all usable GUI themes\n"
|
2003-10-26 13:33:49 +00:00
|
|
|
" -e, --music-driver=MODE Select music driver (see README for details)\n"
|
2003-10-26 21:08:53 +00:00
|
|
|
" -q, --language=LANG Select language (en,de,fr,it,pt,es,jp,zh,kr,se,gb,\n"
|
2004-01-06 12:28:24 +00:00
|
|
|
" hb,ru,cz)\n"
|
2003-10-26 13:33:49 +00:00
|
|
|
" -m, --music-volume=NUM Set the music volume, 0-255 (default: 192)\n"
|
|
|
|
" -s, --sfx-volume=NUM Set the sfx volume, 0-255 (default: 192)\n"
|
2004-04-06 11:50:35 +00:00
|
|
|
" -r, --speech-volume=NUM Set the speech volume, 0-255 (default: 192)\n"
|
2006-01-14 20:05:56 +00:00
|
|
|
" --midi-gain=NUM Set the gain for MIDI playback, 0-1000 (default:\n"
|
2006-10-07 21:22:32 +00:00
|
|
|
" 100) (only supported by some MIDI drivers)\n"
|
2003-12-02 08:09:14 +00:00
|
|
|
" -n, --subtitles Enable subtitles (use with games that have voice)\n"
|
2003-10-26 13:33:49 +00:00
|
|
|
" -b, --boot-param=NUM Pass number to the boot script (boot param)\n"
|
|
|
|
" -d, --debuglevel=NUM Set debug verbosity level\n"
|
2009-04-21 19:49:47 +00:00
|
|
|
" --debugflags=FLAGS Enable engine specific debug flags\n"
|
2006-02-14 23:31:25 +00:00
|
|
|
" (separated by commas)\n"
|
2003-10-26 13:33:49 +00:00
|
|
|
" -u, --dump-scripts Enable script dumping if a directory called 'dumps'\n"
|
|
|
|
" exists in the current directory\n"
|
2002-12-28 12:20:55 +00:00
|
|
|
"\n"
|
2003-10-26 13:33:49 +00:00
|
|
|
" --cdrom=NUM CD drive to play CD audio from (default: 0 = first\n"
|
|
|
|
" drive)\n"
|
2009-04-21 19:49:47 +00:00
|
|
|
" --joystick[=NUM] Enable joystick input (default: 0 = first joystick)\n"
|
2007-03-03 12:59:48 +00:00
|
|
|
" --platform=WORD Specify platform of game (allowed values: 2gs, 3do,\n"
|
2009-01-02 20:36:51 +00:00
|
|
|
" acorn, amiga, atari, c64, fmtowns, nes, mac, pc, pc98,\n"
|
|
|
|
" pce, segacd, wii, windows)\n"
|
2004-11-30 21:07:02 +00:00
|
|
|
" --savepath=PATH Path to where savegames are stored\n"
|
2007-10-28 11:27:00 +00:00
|
|
|
" --extrapath=PATH Extra path to additional game data\n"
|
2005-04-13 12:36:19 +00:00
|
|
|
" --soundfont=FILE Select the SoundFont for MIDI playback (only\n"
|
2005-04-13 00:11:49 +00:00
|
|
|
" supported by some MIDI drivers)\n"
|
2009-05-13 21:02:50 +00:00
|
|
|
" --multi-midi Enable combination AdLib and native MIDI\n"
|
2003-10-26 13:33:49 +00:00
|
|
|
" --native-mt32 True Roland MT-32 (disable GM emulation)\n"
|
2005-04-13 00:11:49 +00:00
|
|
|
" --enable-gs Enable Roland GS mode for MIDI playback\n"
|
2004-07-16 10:24:29 +00:00
|
|
|
" --output-rate=RATE Select output sample rate in Hz (e.g. 22050)\n"
|
2009-05-13 21:02:50 +00:00
|
|
|
" --opl-driver=DRIVER Select AdLib (OPL) emulator (db, mame)\n"
|
2003-10-26 13:33:49 +00:00
|
|
|
" --aspect-ratio Enable aspect ratio correction\n"
|
2005-03-03 12:51:09 +00:00
|
|
|
" --render-mode=MODE Enable additional render modes (cga, ega, hercGreen,\n"
|
2005-04-10 14:33:44 +00:00
|
|
|
" hercAmber, amiga)\n"
|
2002-12-28 12:20:55 +00:00
|
|
|
"\n"
|
2008-05-06 03:00:26 +00:00
|
|
|
#if defined(ENABLE_SKY) || defined(ENABLE_QUEEN)
|
2004-02-13 10:51:33 +00:00
|
|
|
" --alt-intro Use alternative intro for CD versions of Beneath a\n"
|
2004-08-14 19:11:20 +00:00
|
|
|
" Steel Sky and Flight of the Amazon Queen\n"
|
2003-10-26 13:33:49 +00:00
|
|
|
#endif
|
2004-08-14 19:11:20 +00:00
|
|
|
" --copy-protection Enable copy protection in SCUMM games, when\n"
|
|
|
|
" ScummVM disables it by default.\n"
|
2005-10-18 19:05:22 +00:00
|
|
|
" --talkspeed=NUM Set talk speed for games (default: 60)\n"
|
2008-11-14 22:37:32 +00:00
|
|
|
#if defined(ENABLE_SCUMM) || defined(ENABLE_GROOVIE)
|
|
|
|
" --demo-mode Start demo mode of Maniac Mansion or The 7th Guest\n"
|
|
|
|
#endif
|
2008-05-06 03:00:26 +00:00
|
|
|
#ifdef ENABLE_SCUMM
|
2003-10-26 13:33:49 +00:00
|
|
|
" --tempo=NUM Set music tempo (in percent, 50-200) for SCUMM games\n"
|
|
|
|
" (default: 100)\n"
|
2003-07-05 00:57:03 +00:00
|
|
|
#endif
|
2003-07-04 06:54:47 +00:00
|
|
|
"\n"
|
2003-10-26 21:08:53 +00:00
|
|
|
"The meaning of boolean long options can be inverted by prefixing them with\n"
|
|
|
|
"\"no-\", e.g. \"--no-aspect-ratio\".\n"
|
2002-04-12 10:34:46 +00:00
|
|
|
;
|
2003-04-30 12:43:56 +00:00
|
|
|
#endif
|
2003-03-01 22:04:48 +00:00
|
|
|
|
2006-04-11 18:19:54 +00:00
|
|
|
static const char *s_appName = "scummvm";
|
2006-04-02 20:11:50 +00:00
|
|
|
|
|
|
|
static void usage(const char *s, ...) GCC_PRINTF(1, 2);
|
|
|
|
|
|
|
|
static void usage(const char *s, ...) {
|
2006-04-02 17:51:04 +00:00
|
|
|
char buf[STRINGBUFLEN];
|
|
|
|
va_list va;
|
|
|
|
|
|
|
|
va_start(va, s);
|
|
|
|
vsnprintf(buf, STRINGBUFLEN, s, va);
|
|
|
|
va_end(va);
|
|
|
|
|
2008-05-23 12:59:18 +00:00
|
|
|
#if !(defined(__GP32__) || defined (__SYMBIAN32__))
|
2007-02-03 18:09:09 +00:00
|
|
|
printf(USAGE_STRING, s_appName, buf, s_appName, s_appName);
|
2006-04-11 18:19:54 +00:00
|
|
|
#endif
|
2006-04-02 17:51:04 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2004-12-15 12:30:58 +00:00
|
|
|
|
2008-11-13 12:45:35 +00:00
|
|
|
#endif // DISABLE_COMMAND_LINE
|
|
|
|
|
|
|
|
|
2006-05-04 23:37:50 +00:00
|
|
|
void registerDefaults() {
|
2003-05-17 03:06:16 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
// Graphics
|
|
|
|
ConfMan.registerDefault("fullscreen", false);
|
|
|
|
ConfMan.registerDefault("aspect_ratio", false);
|
|
|
|
ConfMan.registerDefault("gfx_mode", "normal");
|
2005-02-20 00:17:22 +00:00
|
|
|
ConfMan.registerDefault("render_mode", "default");
|
2009-08-10 18:03:54 +00:00
|
|
|
ConfMan.registerDefault("desired_screen_aspect_ratio", "auto");
|
2003-09-05 16:30:05 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
// Sound & Music
|
2003-10-15 23:16:52 +00:00
|
|
|
ConfMan.registerDefault("music_volume", 192);
|
|
|
|
ConfMan.registerDefault("sfx_volume", 192);
|
2004-04-06 11:50:35 +00:00
|
|
|
ConfMan.registerDefault("speech_volume", 192);
|
2002-04-27 16:58:29 +00:00
|
|
|
|
2006-05-04 21:14:50 +00:00
|
|
|
ConfMan.registerDefault("music_mute", false);
|
|
|
|
ConfMan.registerDefault("sfx_mute", false);
|
|
|
|
ConfMan.registerDefault("speech_mute", false);
|
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.registerDefault("multi_midi", false);
|
|
|
|
ConfMan.registerDefault("native_mt32", false);
|
2005-04-13 00:11:49 +00:00
|
|
|
ConfMan.registerDefault("enable_gs", false);
|
2006-01-14 20:05:56 +00:00
|
|
|
ConfMan.registerDefault("midi_gain", 100);
|
2003-10-08 21:59:23 +00:00
|
|
|
// ConfMan.registerDefault("music_driver", ???);
|
2002-08-18 23:29:40 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.registerDefault("cdrom", 0);
|
2003-10-01 10:47:19 +00:00
|
|
|
|
2006-01-14 20:05:56 +00:00
|
|
|
// Game specific
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.registerDefault("path", "");
|
2003-10-17 15:38:56 +00:00
|
|
|
ConfMan.registerDefault("platform", Common::kPlatformPC);
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.registerDefault("language", "en");
|
2003-12-21 16:15:37 +00:00
|
|
|
ConfMan.registerDefault("subtitles", false);
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.registerDefault("boot_param", 0);
|
2006-04-15 13:50:44 +00:00
|
|
|
ConfMan.registerDefault("dump_scripts", false);
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.registerDefault("save_slot", -1);
|
2006-04-01 21:55:45 +00:00
|
|
|
ConfMan.registerDefault("autosave_period", 5 * 60); // By default, trigger autosave every 5 minutes
|
2003-07-05 00:57:03 +00:00
|
|
|
|
2008-05-06 03:00:26 +00:00
|
|
|
#if defined(ENABLE_SCUMM) || defined(ENABLE_SWORD2)
|
2004-08-01 06:52:56 +00:00
|
|
|
ConfMan.registerDefault("object_labels", true);
|
|
|
|
#endif
|
|
|
|
|
2003-12-11 06:08:43 +00:00
|
|
|
ConfMan.registerDefault("copy_protection", false);
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.registerDefault("talkspeed", 60);
|
2005-10-18 19:05:22 +00:00
|
|
|
|
2008-11-14 22:37:32 +00:00
|
|
|
#if defined(ENABLE_SCUMM) || defined(ENABLE_GROOVIE)
|
2005-10-18 19:05:22 +00:00
|
|
|
ConfMan.registerDefault("demo_mode", false);
|
2008-11-14 22:37:32 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_SCUMM
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.registerDefault("tempo", 0);
|
2003-07-29 12:13:39 +00:00
|
|
|
#endif
|
|
|
|
|
2008-05-06 03:00:26 +00:00
|
|
|
#if defined(ENABLE_SKY) || defined(ENABLE_QUEEN)
|
2004-02-13 10:51:33 +00:00
|
|
|
ConfMan.registerDefault("alt_intro", false);
|
2003-10-08 21:59:23 +00:00
|
|
|
#endif
|
2002-12-21 00:27:10 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
// Miscellaneous
|
|
|
|
ConfMan.registerDefault("joystick_num", -1);
|
|
|
|
ConfMan.registerDefault("confirm_exit", false);
|
2005-10-18 03:52:21 +00:00
|
|
|
ConfMan.registerDefault("disable_sdl_parachute", false);
|
2002-05-07 05:12:39 +00:00
|
|
|
|
2007-09-19 13:55:05 +00:00
|
|
|
ConfMan.registerDefault("record_mode", "none");
|
|
|
|
ConfMan.registerDefault("record_file_name", "record.bin");
|
|
|
|
ConfMan.registerDefault("record_temp_file_name", "record.tmp");
|
|
|
|
ConfMan.registerDefault("record_time_file_name", "record.time");
|
2002-04-27 16:58:29 +00:00
|
|
|
}
|
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
//
|
|
|
|
// Various macros used by the command line parser.
|
|
|
|
//
|
|
|
|
|
2008-11-13 12:45:35 +00:00
|
|
|
#ifndef DISABLE_COMMAND_LINE
|
|
|
|
|
2005-04-22 21:49:29 +00:00
|
|
|
// Use this for options which have an *optional* value
|
2006-04-02 20:11:50 +00:00
|
|
|
#define DO_OPTION_OPT(shortCmd, longCmd, defaultVal) \
|
2006-07-22 15:16:28 +00:00
|
|
|
if (isLongCmd ? (!strcmp(s+2, longCmd) || !memcmp(s+2, longCmd"=", sizeof(longCmd"=") - 1)) : (tolower(s[1]) == shortCmd)) { \
|
2006-04-15 13:50:44 +00:00
|
|
|
s += 2; \
|
2006-07-22 15:16:28 +00:00
|
|
|
if (isLongCmd) { \
|
|
|
|
s += sizeof(longCmd) - 1; \
|
|
|
|
if (*s == '=') \
|
|
|
|
s++; \
|
|
|
|
} \
|
2006-04-02 20:29:54 +00:00
|
|
|
const char *option = s; \
|
2006-07-22 15:16:28 +00:00
|
|
|
if (*s == '\0' && !isLongCmd) { option = s2; i++; } \
|
2007-05-27 07:37:08 +00:00
|
|
|
if (!option || *option == '\0') option = defaultVal; \
|
2006-04-02 20:11:50 +00:00
|
|
|
if (option) settings[longCmd] = option;
|
2003-10-17 19:39:13 +00:00
|
|
|
|
2005-04-22 21:49:29 +00:00
|
|
|
// Use this for options which have a required (string) value
|
2003-10-17 19:39:13 +00:00
|
|
|
#define DO_OPTION(shortCmd, longCmd) \
|
2006-04-02 20:11:50 +00:00
|
|
|
DO_OPTION_OPT(shortCmd, longCmd, 0) \
|
2007-05-27 07:37:08 +00:00
|
|
|
if (!option) usage("Option '%s' requires an argument", argv[isLongCmd ? i : i-1]);
|
2003-10-17 19:39:13 +00:00
|
|
|
|
2005-04-22 21:49:29 +00:00
|
|
|
// Use this for options which have a required integer value
|
|
|
|
#define DO_OPTION_INT(shortCmd, longCmd) \
|
2007-05-27 07:37:08 +00:00
|
|
|
DO_OPTION(shortCmd, longCmd) \
|
2005-04-22 21:49:29 +00:00
|
|
|
char *endptr = 0; \
|
2006-04-15 13:58:01 +00:00
|
|
|
int intValue; intValue = (int)strtol(option, &endptr, 0); \
|
2006-04-02 20:11:50 +00:00
|
|
|
if (endptr == NULL || *endptr != 0) usage("--%s: Invalid number '%s'", longCmd, option);
|
2005-04-22 21:49:29 +00:00
|
|
|
|
|
|
|
// Use this for boolean options; this distinguishes between "-x" and "-X",
|
|
|
|
// resp. between "--some-option" and "--no-some-option".
|
2003-10-17 19:39:13 +00:00
|
|
|
#define DO_OPTION_BOOL(shortCmd, longCmd) \
|
2006-04-15 13:50:44 +00:00
|
|
|
if (isLongCmd ? (!strcmp(s+2, longCmd) || !strcmp(s+2, "no-"longCmd)) : (tolower(s[1]) == shortCmd)) { \
|
2006-05-13 08:39:12 +00:00
|
|
|
bool boolValue = (islower(s[1]) != 0); \
|
2006-04-15 13:50:44 +00:00
|
|
|
s += 2; \
|
2003-10-17 19:39:13 +00:00
|
|
|
if (isLongCmd) { \
|
2005-04-22 21:49:29 +00:00
|
|
|
boolValue = !strcmp(s, longCmd); \
|
|
|
|
s += boolValue ? (sizeof(longCmd) - 1) : (sizeof("no-"longCmd) - 1); \
|
2003-10-17 19:39:13 +00:00
|
|
|
} \
|
2006-04-02 18:02:16 +00:00
|
|
|
if (*s != '\0') goto unknownOption; \
|
2006-04-02 20:11:50 +00:00
|
|
|
const char *option = boolValue ? "true" : "false"; \
|
|
|
|
settings[longCmd] = option;
|
2003-10-17 19:39:13 +00:00
|
|
|
|
2005-04-22 21:49:29 +00:00
|
|
|
// Use this for options which never have a value, i.e. for 'commands', like "--help".
|
2006-05-04 23:57:49 +00:00
|
|
|
#define DO_COMMAND(shortCmd, longCmd) \
|
2006-04-15 13:50:44 +00:00
|
|
|
if (isLongCmd ? (!strcmp(s+2, longCmd)) : (tolower(s[1]) == shortCmd)) { \
|
|
|
|
s += 2; \
|
2003-10-17 19:39:13 +00:00
|
|
|
if (isLongCmd) \
|
|
|
|
s += sizeof(longCmd) - 1; \
|
2006-05-04 23:57:49 +00:00
|
|
|
if (*s != '\0') goto unknownOption; \
|
|
|
|
return longCmd;
|
2003-10-17 19:39:13 +00:00
|
|
|
|
|
|
|
|
2006-05-04 23:57:49 +00:00
|
|
|
#define DO_LONG_OPTION_OPT(longCmd, d) DO_OPTION_OPT(0, longCmd, d)
|
|
|
|
#define DO_LONG_OPTION(longCmd) DO_OPTION(0, longCmd)
|
|
|
|
#define DO_LONG_OPTION_INT(longCmd) DO_OPTION_INT(0, longCmd)
|
|
|
|
#define DO_LONG_OPTION_BOOL(longCmd) DO_OPTION_BOOL(0, longCmd)
|
|
|
|
#define DO_LONG_COMMAND(longCmd) DO_COMMAND(0, longCmd)
|
2003-10-17 19:39:13 +00:00
|
|
|
|
|
|
|
// End an option handler
|
|
|
|
#define END_OPTION \
|
|
|
|
continue; \
|
|
|
|
}
|
|
|
|
|
2003-11-10 23:17:11 +00:00
|
|
|
|
2009-03-21 16:07:46 +00:00
|
|
|
Common::String parseCommandLine(Common::StringMap &settings, int argc, const char * const *argv) {
|
2006-04-02 20:11:50 +00:00
|
|
|
const char *s, *s2;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-04-02 20:11:50 +00:00
|
|
|
// argv[0] contains the name of the executable.
|
|
|
|
if (argv && argv[0]) {
|
2006-05-04 23:59:12 +00:00
|
|
|
s = strrchr(argv[0], '/');
|
|
|
|
s_appName = s ? (s+1) : argv[0];
|
2006-04-02 20:11:50 +00:00
|
|
|
}
|
2006-04-02 17:51:04 +00:00
|
|
|
|
|
|
|
// We store all command line settings into a string map.
|
2005-04-23 14:39:15 +00:00
|
|
|
|
2006-04-02 17:51:04 +00:00
|
|
|
// Iterate over all command line arguments and parse them into our string map.
|
2006-04-02 20:11:50 +00:00
|
|
|
for (int i = 1; i < argc; ++i) {
|
|
|
|
s = argv[i];
|
|
|
|
s2 = (i < argc-1) ? argv[i+1] : 0;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-04-02 17:51:04 +00:00
|
|
|
if (s[0] != '-') {
|
|
|
|
// The argument doesn't start with a dash, so it's not an option.
|
|
|
|
// Hence it must be the target name. We currently enforce that
|
|
|
|
// this always comes last.
|
|
|
|
if (i != argc - 1)
|
2006-04-02 20:11:50 +00:00
|
|
|
usage("Stray argument '%s'", s);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2006-04-02 21:28:01 +00:00
|
|
|
// We defer checking whether this is a valid target to a later point.
|
|
|
|
return s;
|
2003-10-17 19:39:13 +00:00
|
|
|
} else {
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2006-04-02 20:11:50 +00:00
|
|
|
bool isLongCmd = (s[0] == '-' && s[1] == '-');
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2006-05-04 23:57:49 +00:00
|
|
|
DO_COMMAND('h', "help")
|
2006-04-02 17:51:04 +00:00
|
|
|
END_OPTION
|
|
|
|
|
2006-05-04 23:57:49 +00:00
|
|
|
DO_COMMAND('v', "version")
|
2006-04-02 17:51:04 +00:00
|
|
|
END_OPTION
|
|
|
|
|
2006-05-04 23:57:49 +00:00
|
|
|
DO_COMMAND('t', "list-targets")
|
2006-04-02 17:51:04 +00:00
|
|
|
END_OPTION
|
|
|
|
|
2006-05-04 23:57:49 +00:00
|
|
|
DO_COMMAND('z', "list-games")
|
2006-04-02 17:51:04 +00:00
|
|
|
END_OPTION
|
|
|
|
|
2009-06-07 12:47:10 +00:00
|
|
|
#ifdef DETECTOR_TESTING_HACK
|
2006-05-04 23:57:49 +00:00
|
|
|
// HACK FIXME TODO: This command is intentionally *not* documented!
|
|
|
|
DO_LONG_COMMAND("test-detector")
|
2006-04-25 21:31:55 +00:00
|
|
|
END_OPTION
|
2009-06-07 12:47:10 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef UPGRADE_ALL_TARGETS_HACK
|
|
|
|
// HACK FIXME TODO: This command is intentionally *not* documented!
|
|
|
|
DO_LONG_COMMAND("upgrade-targets")
|
|
|
|
END_OPTION
|
|
|
|
#endif
|
2006-04-25 21:31:55 +00:00
|
|
|
|
2008-02-04 10:15:21 +00:00
|
|
|
DO_LONG_OPTION("list-saves")
|
|
|
|
// FIXME: Need to document this.
|
|
|
|
// TODO: Make the argument optional. If no argument is given, list all savegames
|
|
|
|
// for all configured targets.
|
|
|
|
return "list-saves";
|
|
|
|
END_OPTION
|
2006-04-02 17:51:04 +00:00
|
|
|
|
2004-02-07 04:53:59 +00:00
|
|
|
DO_OPTION('c', "config")
|
|
|
|
END_OPTION
|
|
|
|
|
2005-04-22 21:49:29 +00:00
|
|
|
DO_OPTION_INT('b', "boot-param")
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-04-02 20:11:50 +00:00
|
|
|
DO_OPTION_OPT('d', "debuglevel", "0")
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-02-14 23:31:25 +00:00
|
|
|
DO_LONG_OPTION("debugflags")
|
|
|
|
END_OPTION
|
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION('e', "music-driver")
|
2009-03-26 13:52:43 +00:00
|
|
|
if (MidiDriver::findMusicDriver(option) == 0)
|
2006-04-02 20:11:50 +00:00
|
|
|
usage("Unrecognized music driver '%s'", option);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2005-04-22 21:49:29 +00:00
|
|
|
DO_LONG_OPTION_INT("output-rate")
|
2004-07-16 10:24:29 +00:00
|
|
|
END_OPTION
|
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION_BOOL('f', "fullscreen")
|
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2009-05-13 20:57:37 +00:00
|
|
|
DO_LONG_OPTION("opl-driver")
|
|
|
|
END_OPTION
|
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION('g', "gfx-mode")
|
2004-02-24 22:39:42 +00:00
|
|
|
// Check whether 'option' specifies a valid graphics mode.
|
|
|
|
bool isValid = false;
|
|
|
|
if (!scumm_stricmp(option, "normal") || !scumm_stricmp(option, "default"))
|
|
|
|
isValid = true;
|
|
|
|
if (!isValid) {
|
|
|
|
const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
|
|
|
|
while (gm->name && !isValid) {
|
|
|
|
isValid = !scumm_stricmp(gm->name, option);
|
|
|
|
gm++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!isValid)
|
2006-04-02 20:11:50 +00:00
|
|
|
usage("Unrecognized graphics mode '%s'", option);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2005-04-22 21:49:29 +00:00
|
|
|
DO_OPTION_INT('m', "music-volume")
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-12-02 08:09:14 +00:00
|
|
|
DO_OPTION_BOOL('n', "subtitles")
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION('p', "path")
|
2008-10-02 16:58:59 +00:00
|
|
|
Common::FSNode path(option);
|
2007-09-18 20:16:33 +00:00
|
|
|
if (!path.exists()) {
|
2007-06-16 17:20:46 +00:00
|
|
|
usage("Non-existent game path '%s'", option);
|
2007-09-18 20:16:33 +00:00
|
|
|
} else if (!path.isReadable()) {
|
2007-06-16 17:20:46 +00:00
|
|
|
usage("Non-readable game path '%s'", option);
|
|
|
|
}
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION('q', "language")
|
2003-10-17 15:35:46 +00:00
|
|
|
if (Common::parseLanguage(option) == Common::UNK_LANG)
|
2006-04-02 20:11:50 +00:00
|
|
|
usage("Unrecognized language '%s'", option);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2005-04-22 21:49:29 +00:00
|
|
|
DO_OPTION_INT('s', "sfx-volume")
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2005-04-22 21:49:29 +00:00
|
|
|
DO_OPTION_INT('r', "speech-volume")
|
2004-04-05 18:24:36 +00:00
|
|
|
END_OPTION
|
|
|
|
|
2006-01-14 20:05:56 +00:00
|
|
|
DO_LONG_OPTION_INT("midi-gain")
|
|
|
|
END_OPTION
|
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION_BOOL('u', "dump-scripts")
|
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2006-04-02 20:11:50 +00:00
|
|
|
DO_OPTION_OPT('x', "save-slot", "0")
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2005-04-22 21:49:29 +00:00
|
|
|
DO_LONG_OPTION_INT("cdrom")
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2006-04-02 20:11:50 +00:00
|
|
|
DO_LONG_OPTION_OPT("joystick", "0")
|
2007-01-24 00:07:23 +00:00
|
|
|
settings["joystick_num"] = option;
|
|
|
|
settings.erase("joystick");
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_LONG_OPTION("platform")
|
|
|
|
int platform = Common::parsePlatform(option);
|
|
|
|
if (platform == Common::kPlatformUnknown)
|
2006-04-02 20:11:50 +00:00
|
|
|
usage("Unrecognized platform '%s'", option);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2005-04-10 14:33:44 +00:00
|
|
|
DO_LONG_OPTION("soundfont")
|
2008-10-02 16:58:59 +00:00
|
|
|
Common::FSNode path(option);
|
2007-09-18 20:16:33 +00:00
|
|
|
if (!path.exists()) {
|
2007-06-16 17:20:46 +00:00
|
|
|
usage("Non-existent soundfont path '%s'", option);
|
2007-09-18 20:16:33 +00:00
|
|
|
} else if (!path.isReadable()) {
|
2007-06-16 17:20:46 +00:00
|
|
|
usage("Non-readable soundfont path '%s'", option);
|
|
|
|
}
|
2005-04-10 14:33:44 +00:00
|
|
|
END_OPTION
|
|
|
|
|
2005-10-18 03:52:21 +00:00
|
|
|
DO_LONG_OPTION_BOOL("disable-sdl-parachute")
|
|
|
|
END_OPTION
|
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_LONG_OPTION_BOOL("multi-midi")
|
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_LONG_OPTION_BOOL("native-mt32")
|
2005-04-13 00:11:49 +00:00
|
|
|
END_OPTION
|
|
|
|
|
|
|
|
DO_LONG_OPTION_BOOL("enable-gs")
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_LONG_OPTION_BOOL("aspect-ratio")
|
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2005-02-20 00:17:22 +00:00
|
|
|
DO_LONG_OPTION("render-mode")
|
|
|
|
int renderMode = Common::parseRenderMode(option);
|
|
|
|
if (renderMode == Common::kRenderDefault)
|
2006-04-02 20:11:50 +00:00
|
|
|
usage("Unrecognized render mode '%s'", option);
|
2005-02-20 00:17:22 +00:00
|
|
|
END_OPTION
|
|
|
|
|
2004-01-29 21:54:03 +00:00
|
|
|
DO_LONG_OPTION("savepath")
|
2008-10-02 16:58:59 +00:00
|
|
|
Common::FSNode path(option);
|
2007-09-18 20:16:33 +00:00
|
|
|
if (!path.exists()) {
|
2007-06-16 17:20:46 +00:00
|
|
|
usage("Non-existent savegames path '%s'", option);
|
2007-09-18 20:16:33 +00:00
|
|
|
} else if (!path.isWritable()) {
|
2007-06-16 17:20:46 +00:00
|
|
|
usage("Non-writable savegames path '%s'", option);
|
|
|
|
}
|
2004-01-29 21:54:03 +00:00
|
|
|
END_OPTION
|
|
|
|
|
2007-10-28 11:27:00 +00:00
|
|
|
DO_LONG_OPTION("extrapath")
|
2008-10-02 16:58:59 +00:00
|
|
|
Common::FSNode path(option);
|
2007-10-28 11:27:00 +00:00
|
|
|
if (!path.exists()) {
|
|
|
|
usage("Non-existent extra path '%s'", option);
|
|
|
|
} else if (!path.isReadable()) {
|
|
|
|
usage("Non-readable extra path '%s'", option);
|
|
|
|
}
|
|
|
|
END_OPTION
|
|
|
|
|
2005-10-18 19:05:22 +00:00
|
|
|
DO_LONG_OPTION_INT("talkspeed")
|
|
|
|
END_OPTION
|
|
|
|
|
|
|
|
DO_LONG_OPTION_BOOL("copy-protection")
|
|
|
|
END_OPTION
|
|
|
|
|
2006-01-31 17:52:56 +00:00
|
|
|
DO_LONG_OPTION("gui-theme")
|
|
|
|
END_OPTION
|
|
|
|
|
2006-06-14 19:32:26 +00:00
|
|
|
DO_LONG_OPTION("themepath")
|
2008-10-02 16:58:59 +00:00
|
|
|
Common::FSNode path(option);
|
2007-09-18 20:16:33 +00:00
|
|
|
if (!path.exists()) {
|
2007-06-16 17:20:46 +00:00
|
|
|
usage("Non-existent theme path '%s'", option);
|
2007-09-18 20:16:33 +00:00
|
|
|
} else if (!path.isReadable()) {
|
2007-06-16 17:20:46 +00:00
|
|
|
usage("Non-readable theme path '%s'", option);
|
|
|
|
}
|
2006-06-14 19:32:26 +00:00
|
|
|
END_OPTION
|
|
|
|
|
2009-01-02 20:21:21 +00:00
|
|
|
DO_LONG_COMMAND("list-themes")
|
|
|
|
END_OPTION
|
|
|
|
|
2006-03-26 04:22:47 +00:00
|
|
|
DO_LONG_OPTION("target-md5")
|
|
|
|
END_OPTION
|
|
|
|
|
2008-05-06 03:00:26 +00:00
|
|
|
#ifdef ENABLE_SCUMM
|
2006-04-15 13:58:01 +00:00
|
|
|
DO_LONG_OPTION_INT("tempo")
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2008-11-14 22:37:32 +00:00
|
|
|
#endif
|
|
|
|
#if defined(ENABLE_SCUMM) || defined(ENABLE_GROOVIE)
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_LONG_OPTION_BOOL("demo-mode")
|
|
|
|
END_OPTION
|
|
|
|
#endif
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2008-05-06 03:00:26 +00:00
|
|
|
#if defined(ENABLE_SKY) || defined(ENABLE_QUEEN)
|
2004-02-13 10:51:33 +00:00
|
|
|
DO_LONG_OPTION_BOOL("alt-intro")
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-07-05 00:57:03 +00:00
|
|
|
#endif
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2007-09-19 13:55:05 +00:00
|
|
|
DO_LONG_OPTION("record-mode")
|
|
|
|
END_OPTION
|
|
|
|
|
|
|
|
DO_LONG_OPTION("record-file-name")
|
|
|
|
END_OPTION
|
|
|
|
|
|
|
|
DO_LONG_OPTION("record-temp-file-name")
|
|
|
|
END_OPTION
|
|
|
|
|
|
|
|
DO_LONG_OPTION("record-time-file-name")
|
|
|
|
END_OPTION
|
|
|
|
|
2007-11-13 08:06:15 +00:00
|
|
|
#ifdef IPHONE
|
|
|
|
// This is automatically set when launched from the Springboard.
|
|
|
|
DO_LONG_OPTION_OPT("launchedFromSB", 0)
|
|
|
|
END_OPTION
|
|
|
|
#endif
|
2007-09-19 13:55:05 +00:00
|
|
|
|
2006-04-02 17:51:04 +00:00
|
|
|
unknownOption:
|
2003-10-17 19:39:13 +00:00
|
|
|
// If we get till here, the option is unhandled and hence unknown.
|
2006-04-02 20:11:50 +00:00
|
|
|
usage("Unrecognized option '%s'", argv[i]);
|
2002-04-11 17:19:16 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-02 21:06:49 +00:00
|
|
|
|
2008-11-13 12:45:35 +00:00
|
|
|
return Common::String();
|
2006-04-02 20:11:50 +00:00
|
|
|
}
|
|
|
|
|
2006-05-04 23:57:49 +00:00
|
|
|
/** List all supported game IDs, i.e. all games which any loaded plugin supports. */
|
|
|
|
static void listGames() {
|
|
|
|
printf("Game ID Full Title \n"
|
|
|
|
"-------------------- ------------------------------------------------------\n");
|
|
|
|
|
2008-05-26 00:28:48 +00:00
|
|
|
const EnginePlugin::List &plugins = EngineMan.getPlugins();
|
|
|
|
EnginePlugin::List::const_iterator iter = plugins.begin();
|
2006-05-04 23:57:49 +00:00
|
|
|
for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
|
2008-05-13 09:30:23 +00:00
|
|
|
GameList list = (**iter)->getSupportedGames();
|
2006-05-04 23:57:49 +00:00
|
|
|
for (GameList::iterator v = list.begin(); v != list.end(); ++v) {
|
2007-01-20 21:27:57 +00:00
|
|
|
printf("%-20s %s\n", v->gameid().c_str(), v->description().c_str());
|
2006-05-04 23:57:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** List all targets which are configured in the config file. */
|
|
|
|
static void listTargets() {
|
|
|
|
printf("Target Description \n"
|
|
|
|
"-------------------- ------------------------------------------------------\n");
|
|
|
|
|
2006-07-31 13:41:21 +00:00
|
|
|
using namespace Common;
|
|
|
|
const ConfigManager::DomainMap &domains = ConfMan.getGameDomains();
|
2008-02-04 10:15:21 +00:00
|
|
|
ConfigManager::DomainMap::const_iterator iter;
|
2006-05-04 23:57:49 +00:00
|
|
|
for (iter = domains.begin(); iter != domains.end(); ++iter) {
|
|
|
|
Common::String name(iter->_key);
|
|
|
|
Common::String description(iter->_value.get("description"));
|
|
|
|
|
|
|
|
if (description.empty()) {
|
|
|
|
// FIXME: At this point, we should check for a "gameid" override
|
|
|
|
// to find the proper desc. In fact, the platform probably should
|
|
|
|
// be taken into account, too.
|
|
|
|
Common::String gameid(name);
|
2008-05-12 00:26:29 +00:00
|
|
|
GameDescriptor g = EngineMan.findGame(gameid);
|
2007-01-21 00:29:03 +00:00
|
|
|
if (g.description().size() > 0)
|
|
|
|
description = g.description();
|
2006-05-04 23:57:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
printf("%-20s %s\n", name.c_str(), description.c_str());
|
2008-02-04 10:15:21 +00:00
|
|
|
|
2006-05-04 23:57:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-04 10:15:21 +00:00
|
|
|
/** List all saves states for the given target. */
|
|
|
|
static void listSaves(const char *target) {
|
|
|
|
// FIXME HACK
|
|
|
|
g_system->initBackend();
|
|
|
|
|
|
|
|
// Grab the "target" domain, if any
|
|
|
|
const Common::ConfigManager::Domain *domain = ConfMan.getDomain(target);
|
|
|
|
|
2008-10-21 16:01:06 +00:00
|
|
|
// Set up the game domain as newly active domain, so
|
|
|
|
// target specific savepath will be checked
|
|
|
|
Common::String oldDomain = ConfMan.getActiveDomainName();
|
|
|
|
ConfMan.setActiveDomain(target);
|
|
|
|
|
2008-02-04 10:15:21 +00:00
|
|
|
// Grab the gameid from the domain resp. use the target as gameid
|
|
|
|
Common::String gameid;
|
|
|
|
if (domain)
|
|
|
|
gameid = domain->get("gameid");
|
|
|
|
if (gameid.empty())
|
|
|
|
gameid = target;
|
|
|
|
gameid.toLowercase(); // Normalize it to lower case
|
|
|
|
|
|
|
|
// Find the plugin that will handle the specified gameid
|
2008-05-12 00:26:29 +00:00
|
|
|
const EnginePlugin *plugin = 0;
|
|
|
|
GameDescriptor game = EngineMan.findGame(gameid, &plugin);
|
2008-02-04 10:15:21 +00:00
|
|
|
|
|
|
|
if (!plugin) {
|
|
|
|
error("Could not find any plugin to handle gameid '%s' (target '%s')", gameid.c_str(), target);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Query the plugin for a list of savegames
|
2008-05-13 09:30:23 +00:00
|
|
|
SaveStateList saveList = (*plugin)->listSaves(target);
|
2008-02-04 10:15:21 +00:00
|
|
|
|
|
|
|
// TODO: Include more info about the target (desc, engine name, ...) ???
|
|
|
|
printf("Saves for target '%s':\n", target);
|
|
|
|
printf(" Slot Description \n"
|
|
|
|
" ---- ------------------------------------------------------\n");
|
|
|
|
|
|
|
|
for (SaveStateList::const_iterator x = saveList.begin(); x != saveList.end(); ++x) {
|
|
|
|
printf(" %-4s %s\n", x->save_slot().c_str(), x->description().c_str());
|
|
|
|
// TODO: Could also iterate over the full hashmap, printing all key-value pairs
|
|
|
|
}
|
2008-10-21 16:01:06 +00:00
|
|
|
|
|
|
|
// Revert to the old active domain
|
|
|
|
ConfMan.setActiveDomain(oldDomain);
|
2008-02-04 10:15:21 +00:00
|
|
|
}
|
|
|
|
|
2009-01-02 20:21:21 +00:00
|
|
|
/** Lists all usable themes */
|
|
|
|
static void listThemes() {
|
2009-01-02 21:24:13 +00:00
|
|
|
typedef Common::List<GUI::ThemeEngine::ThemeDescriptor> ThList;
|
2009-01-02 20:21:21 +00:00
|
|
|
ThList thList;
|
2009-01-02 21:24:13 +00:00
|
|
|
GUI::ThemeEngine::listUsableThemes(thList);
|
2009-01-02 20:21:21 +00:00
|
|
|
|
|
|
|
printf("Theme Description\n");
|
|
|
|
printf("-------------- ------------------------------------------------\n");
|
|
|
|
|
|
|
|
for (ThList::const_iterator i = thList.begin(); i != thList.end(); ++i)
|
|
|
|
printf("%-14s %s\n", i->id.c_str(), i->name.c_str());
|
|
|
|
}
|
|
|
|
|
2008-02-04 10:15:21 +00:00
|
|
|
|
2006-05-04 23:57:49 +00:00
|
|
|
#ifdef DETECTOR_TESTING_HACK
|
|
|
|
static void runDetectorTest() {
|
|
|
|
// HACK: The following code can be used to test the detection code of our
|
|
|
|
// engines. Basically, it loops over all targets, and calls the detector
|
|
|
|
// for the given path. It then prints out the result and also checks
|
|
|
|
// whether the result agrees with the settings of the target.
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-05-04 23:57:49 +00:00
|
|
|
const Common::ConfigManager::DomainMap &domains = ConfMan.getGameDomains();
|
|
|
|
Common::ConfigManager::DomainMap::const_iterator iter = domains.begin();
|
|
|
|
int success = 0, failure = 0;
|
|
|
|
for (iter = domains.begin(); iter != domains.end(); ++iter) {
|
|
|
|
Common::String name(iter->_key);
|
|
|
|
Common::String gameid(iter->_value.get("gameid"));
|
|
|
|
Common::String path(iter->_value.get("path"));
|
|
|
|
printf("Looking at target '%s', gameid '%s', path '%s' ...\n",
|
|
|
|
name.c_str(), gameid.c_str(), path.c_str());
|
|
|
|
if (path.empty()) {
|
|
|
|
printf(" ... no path specified, skipping\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (gameid.empty()) {
|
|
|
|
gameid = name;
|
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2008-10-02 16:58:59 +00:00
|
|
|
Common::FSNode dir(path);
|
2008-09-03 11:22:51 +00:00
|
|
|
Common::FSList files;
|
2008-10-02 16:58:59 +00:00
|
|
|
if (!dir.getChildren(files, Common::FSNode::kListAll)) {
|
2006-05-04 23:57:49 +00:00
|
|
|
printf(" ... invalid path, skipping\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-05-12 00:26:29 +00:00
|
|
|
GameList candidates(EngineMan.detectGames(files));
|
2006-05-04 23:57:49 +00:00
|
|
|
bool gameidDiffers = false;
|
2007-01-20 21:27:57 +00:00
|
|
|
GameList::iterator x;
|
2006-06-01 22:43:19 +00:00
|
|
|
for (x = candidates.begin(); x != candidates.end(); ++x) {
|
2007-01-20 21:27:57 +00:00
|
|
|
gameidDiffers |= (scumm_stricmp(gameid.c_str(), x->gameid().c_str()) != 0);
|
2006-05-04 23:57:49 +00:00
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-05-04 23:57:49 +00:00
|
|
|
if (candidates.empty()) {
|
|
|
|
printf(" FAILURE: No games detected\n");
|
|
|
|
failure++;
|
|
|
|
} else if (candidates.size() > 1) {
|
|
|
|
if (gameidDiffers) {
|
2008-07-29 00:49:44 +00:00
|
|
|
printf(" WARNING: Multiple games detected, some/all with wrong gameid\n");
|
2006-05-04 23:57:49 +00:00
|
|
|
} else {
|
2009-06-07 12:47:10 +00:00
|
|
|
printf(" WARNING: Multiple games detected, but all have matching gameid\n");
|
2006-05-04 23:57:49 +00:00
|
|
|
}
|
|
|
|
failure++;
|
|
|
|
} else if (gameidDiffers) {
|
|
|
|
printf(" FAILURE: Wrong gameid detected\n");
|
|
|
|
failure++;
|
|
|
|
} else {
|
|
|
|
printf(" SUCCESS: Game was detected correctly\n");
|
|
|
|
success++;
|
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-06-01 22:43:19 +00:00
|
|
|
for (x = candidates.begin(); x != candidates.end(); ++x) {
|
2006-05-04 23:57:49 +00:00
|
|
|
printf(" gameid '%s', desc '%s', language '%s', platform '%s'\n",
|
2007-01-20 21:27:57 +00:00
|
|
|
x->gameid().c_str(),
|
|
|
|
x->description().c_str(),
|
|
|
|
Common::getLanguageCode(x->language()),
|
|
|
|
Common::getPlatformCode(x->platform()));
|
2006-05-04 23:57:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
int total = domains.size();
|
|
|
|
printf("Detector test run: %d fail, %d success, %d skipped, out of %d\n",
|
|
|
|
failure, success, total - failure - success, total);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-06-07 12:47:10 +00:00
|
|
|
#ifdef UPGRADE_ALL_TARGETS_HACK
|
|
|
|
void upgradeTargets() {
|
|
|
|
// HACK: The following upgrades all your targets to the latest and
|
|
|
|
// greatest. Right now that means updating the guioptions and (optionally)
|
|
|
|
// also the game descriptions.
|
|
|
|
// Basically, it loops over all targets, and calls the detector for the
|
|
|
|
// given path. It then compares the result with the settings of the target.
|
|
|
|
// If the basics seem to match, it updates the guioptions.
|
|
|
|
|
|
|
|
printf("Upgrading all your existing targets\n");
|
|
|
|
|
|
|
|
Common::ConfigManager::DomainMap &domains = ConfMan.getGameDomains();
|
|
|
|
Common::ConfigManager::DomainMap::iterator iter = domains.begin();
|
|
|
|
for (iter = domains.begin(); iter != domains.end(); ++iter) {
|
|
|
|
Common::ConfigManager::Domain &dom = iter->_value;
|
|
|
|
Common::String name(iter->_key);
|
|
|
|
Common::String gameid(dom.get("gameid"));
|
|
|
|
Common::String path(dom.get("path"));
|
|
|
|
printf("Looking at target '%s', gameid '%s' ...\n",
|
|
|
|
name.c_str(), gameid.c_str());
|
|
|
|
if (path.empty()) {
|
|
|
|
printf(" ... no path specified, skipping\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (gameid.empty()) {
|
|
|
|
gameid = name;
|
|
|
|
}
|
|
|
|
gameid.toLowercase(); // TODO: Is this paranoia? Maybe we should just assume all lowercase, always?
|
|
|
|
|
|
|
|
Common::FSNode dir(path);
|
|
|
|
Common::FSList files;
|
|
|
|
if (!dir.getChildren(files, Common::FSNode::kListAll)) {
|
|
|
|
printf(" ... invalid path, skipping\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Language lang = Common::parseLanguage(dom.get("language"));
|
|
|
|
Common::Platform plat = Common::parsePlatform(dom.get("platform"));
|
|
|
|
Common::String desc(dom.get("description"));
|
|
|
|
|
|
|
|
GameList candidates(EngineMan.detectGames(files));
|
|
|
|
GameDescriptor *g = 0;
|
|
|
|
|
|
|
|
// We proceed as follows:
|
|
|
|
// * If detection failed to produce candidates, skip.
|
|
|
|
// * If there is a unique detector match, trust it.
|
|
|
|
// * If there are multiple match, run over them comparing gameid, language and platform.
|
|
|
|
// If we end up with a unique match, use it. Otherwise, skip.
|
|
|
|
if (candidates.size() == 0) {
|
|
|
|
printf(" ... failed to detect game, skipping\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (candidates.size() > 1) {
|
|
|
|
// Scan over all candidates, check if there is a unique match for gameid, language and platform
|
|
|
|
GameList::iterator x;
|
|
|
|
int matchesFound = 0;
|
|
|
|
for (x = candidates.begin(); x != candidates.end(); ++x) {
|
|
|
|
if (x->gameid() == gameid && x->language() == lang && x->platform() == plat) {
|
|
|
|
matchesFound++;
|
|
|
|
g = &(*x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (matchesFound != 1) {
|
|
|
|
printf(" ... detected multiple games, could not establish unique match, skipping\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Unique match -> use it
|
|
|
|
g = &candidates[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
// At this point, g points to a GameDescriptor which we can use to update
|
|
|
|
// the target referred to by dom. We update several things
|
|
|
|
|
|
|
|
// Always set the gameid explicitly (in case of legacy targets)
|
|
|
|
dom["gameid"] = g->gameid();
|
|
|
|
|
|
|
|
// Always set the GUI options. The user should not modify them, and engines might
|
|
|
|
// gain more features over time, so we want to keep this list up-to-date.
|
|
|
|
if (g->contains("guioptions")) {
|
|
|
|
printf(" -> update guioptions to '%s'\n", (*g)["guioptions"].c_str());
|
|
|
|
dom["guioptions"] = (*g)["guioptions"];
|
|
|
|
} else if (dom.contains("guioptions")) {
|
|
|
|
dom.erase("guioptions");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the language setting but only if none has been set yet.
|
|
|
|
if (lang == Common::UNK_LANG && g->language() != Common::UNK_LANG) {
|
2009-06-07 17:05:58 +00:00
|
|
|
printf(" -> set language to '%s'\n", Common::getLanguageCode(g->language()));
|
2009-06-07 12:47:10 +00:00
|
|
|
dom["language"] = (*g)["language"];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the platform setting but only if none has been set yet.
|
|
|
|
if (plat == Common::kPlatformUnknown && g->platform() != Common::kPlatformUnknown) {
|
2009-06-07 17:05:58 +00:00
|
|
|
printf(" -> set platform to '%s'\n", Common::getPlatformCode(g->platform()));
|
2009-06-07 12:47:10 +00:00
|
|
|
dom["platform"] = (*g)["platform"];
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: We could also update the description. But not everybody will want that.
|
|
|
|
// Esp. because for some games (e.g. the combined Zak/Loom FM-TOWNS demo etc.)
|
|
|
|
// ScummVM still generates an incorrect description string. So, the description
|
|
|
|
// should only be updated if the user explicitly requests this.
|
|
|
|
#if 0
|
|
|
|
if (desc != g->description()) {
|
|
|
|
printf(" -> update desc from '%s' to\n '%s' ?\n", desc.c_str(), g->description().c_str());
|
|
|
|
dom["description"] = (*g)["description"];
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// Finally, save our changes to disk
|
|
|
|
ConfMan.flushToDisk();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-11-13 12:45:35 +00:00
|
|
|
#else // DISABLE_COMMAND_LINE
|
|
|
|
|
|
|
|
|
2009-03-21 16:07:46 +00:00
|
|
|
Common::String parseCommandLine(Common::StringMap &settings, int argc, const char * const *argv) {
|
2008-11-13 12:45:35 +00:00
|
|
|
return Common::String();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif // DISABLE_COMMAND_LINE
|
|
|
|
|
|
|
|
|
2006-05-04 23:57:49 +00:00
|
|
|
bool processSettings(Common::String &command, Common::StringMap &settings) {
|
|
|
|
|
2008-11-13 12:45:35 +00:00
|
|
|
#ifndef DISABLE_COMMAND_LINE
|
|
|
|
|
2006-05-04 23:57:49 +00:00
|
|
|
// Handle commands passed via the command line (like --list-targets and
|
|
|
|
// --list-games). This must be done after the config file and the plugins
|
|
|
|
// have been loaded.
|
|
|
|
if (command == "list-targets") {
|
|
|
|
listTargets();
|
|
|
|
return false;
|
|
|
|
} else if (command == "list-games") {
|
|
|
|
listGames();
|
|
|
|
return false;
|
2008-02-04 10:15:21 +00:00
|
|
|
} else if (command == "list-saves") {
|
|
|
|
listSaves(settings["list-saves"].c_str());
|
|
|
|
return false;
|
2009-01-02 20:21:21 +00:00
|
|
|
} else if (command == "list-themes") {
|
|
|
|
listThemes();
|
|
|
|
return false;
|
2006-05-04 23:57:49 +00:00
|
|
|
} else if (command == "version") {
|
|
|
|
printf("%s\n", gScummVMFullVersion);
|
|
|
|
printf("Features compiled in: %s\n", gScummVMFeatures);
|
|
|
|
return false;
|
|
|
|
} else if (command == "help") {
|
2006-05-23 14:19:38 +00:00
|
|
|
printf(HELP_STRING, s_appName);
|
2006-05-04 23:57:49 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#ifdef DETECTOR_TESTING_HACK
|
|
|
|
else if (command == "test-detector") {
|
|
|
|
runDetectorTest();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
2009-06-07 12:47:10 +00:00
|
|
|
#ifdef UPGRADE_ALL_TARGETS_HACK
|
|
|
|
else if (command == "upgrade-targets") {
|
|
|
|
upgradeTargets();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
2006-04-02 20:11:50 +00:00
|
|
|
|
2008-11-13 12:45:35 +00:00
|
|
|
#endif // DISABLE_COMMAND_LINE
|
|
|
|
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2006-04-02 17:51:04 +00:00
|
|
|
// If a target was specified, check whether there is either a game
|
|
|
|
// domain (i.e. a target) matching this argument, or alternatively
|
|
|
|
// whether there is a gameid matching that name.
|
2006-05-04 23:57:49 +00:00
|
|
|
if (!command.empty()) {
|
2008-05-12 00:26:29 +00:00
|
|
|
GameDescriptor gd = EngineMan.findGame(command);
|
2007-01-28 10:29:22 +00:00
|
|
|
if (ConfMan.hasGameDomain(command) || !gd.gameid().empty()) {
|
2007-06-11 08:38:23 +00:00
|
|
|
bool idCameFromCommandLine = false;
|
|
|
|
|
|
|
|
// WORKAROUND: Fix for bug #1719463: "DETECTOR: Launching
|
|
|
|
// undefined target adds launcher entry"
|
|
|
|
//
|
|
|
|
// We designate gameids which come strictly from command line
|
|
|
|
// so AdvancedDetector will not save config file with invalid
|
|
|
|
// gameid in case target autoupgrade was performed
|
|
|
|
if (!ConfMan.hasGameDomain(command)) {
|
|
|
|
idCameFromCommandLine = true;
|
|
|
|
}
|
|
|
|
|
2006-05-05 00:26:03 +00:00
|
|
|
ConfMan.setActiveDomain(command);
|
2007-06-11 08:38:23 +00:00
|
|
|
|
|
|
|
if (idCameFromCommandLine)
|
|
|
|
ConfMan.set("id_came_from_command_line", "1");
|
|
|
|
|
2006-04-02 17:51:04 +00:00
|
|
|
} else {
|
2008-11-13 12:45:35 +00:00
|
|
|
#ifndef DISABLE_COMMAND_LINE
|
2006-05-04 23:57:49 +00:00
|
|
|
usage("Unrecognized game target '%s'", command.c_str());
|
2008-11-13 12:45:35 +00:00
|
|
|
#endif // DISABLE_COMMAND_LINE
|
2006-04-02 17:51:04 +00:00
|
|
|
}
|
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-04-02 17:51:04 +00:00
|
|
|
|
|
|
|
// The user can override the savepath with the SCUMMVM_SAVEPATH
|
|
|
|
// environment variable. This is weaker than a --savepath on the
|
|
|
|
// command line, but overrides the default savepath, hence it is
|
|
|
|
// handled here, just before the command line gets parsed.
|
2006-04-13 02:39:59 +00:00
|
|
|
#if !defined(MACOS_CARBON) && !defined(_WIN32_WCE) && !defined(PALMOS_MODE) && !defined(__GP32__)
|
2006-04-02 17:51:04 +00:00
|
|
|
if (!settings.contains("savepath")) {
|
|
|
|
const char *dir = getenv("SCUMMVM_SAVEPATH");
|
2006-04-14 14:26:34 +00:00
|
|
|
if (dir && *dir && strlen(dir) < MAXPATHLEN) {
|
2008-10-02 16:58:59 +00:00
|
|
|
Common::FSNode saveDir(dir);
|
2007-09-18 20:16:33 +00:00
|
|
|
if (!saveDir.exists()) {
|
2007-06-16 17:20:46 +00:00
|
|
|
warning("Non-existent SCUMMVM_SAVEPATH save path. It will be ignored.");
|
2007-09-18 20:16:33 +00:00
|
|
|
} else if (!saveDir.isWritable()) {
|
2007-06-16 17:20:46 +00:00
|
|
|
warning("Non-writable SCUMMVM_SAVEPATH save path. It will be ignored.");
|
|
|
|
} else {
|
|
|
|
settings["savepath"] = dir;
|
|
|
|
}
|
2006-04-02 17:51:04 +00:00
|
|
|
}
|
2003-10-18 00:25:13 +00:00
|
|
|
}
|
2006-04-02 17:51:04 +00:00
|
|
|
#endif
|
|
|
|
|
2005-04-23 14:39:15 +00:00
|
|
|
// Finally, store the command line settings into the config manager.
|
2006-04-02 17:51:04 +00:00
|
|
|
for (Common::StringMap::const_iterator x = settings.begin(); x != settings.end(); ++x) {
|
2006-05-04 23:24:09 +00:00
|
|
|
Common::String key(x->_key);
|
|
|
|
Common::String value(x->_value);
|
2006-04-02 20:11:50 +00:00
|
|
|
|
|
|
|
// Replace any "-" in the key by "_" (e.g. change "save-slot" to "save_slot").
|
2006-05-04 23:24:09 +00:00
|
|
|
for (Common::String::iterator c = key.begin(); c != key.end(); ++c)
|
2006-04-02 20:11:50 +00:00
|
|
|
if (*c == '-')
|
|
|
|
*c = '_';
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-04-02 20:11:50 +00:00
|
|
|
// Store it into ConfMan.
|
|
|
|
ConfMan.set(key, value, Common::ConfigManager::kTransientDomain);
|
2006-04-02 17:51:04 +00:00
|
|
|
}
|
2006-05-04 23:57:49 +00:00
|
|
|
|
|
|
|
return true;
|
2002-03-23 20:34:47 +00:00
|
|
|
}
|
2006-05-04 23:37:50 +00:00
|
|
|
|
|
|
|
} // End of namespace Base
|