[Add] -S/--sound option to force sound. Disabled sound by default.

This commit is contained in:
Allanis 2013-03-21 19:55:35 +00:00
parent 6a7c051851
commit 32bd075c9a

View File

@ -60,15 +60,16 @@ static void print_usage(char** argv);
static void print_usage(char** argv) { static void print_usage(char** argv) {
LOG("USAGE: %s [OPTION]", argv[0]); LOG("USAGE: %s [OPTION]", argv[0]);
LOG("Options are:"); LOG("Options are:");
LOG("\t-f, --fullscreen - Fullscreen"); LOG(" -f, --fullscreen - Fullscreen");
LOG("\t-F, --fps - Limit frames per second"); LOG(" -F, --fps - Limit frames per second");
LOG("\t-d s, --data s - Set the data file to be s"); LOG(" -d s, --data s - Set the data file to be s");
LOG("\t-j n, --joystick n - Use joystick (n)"); LOG(" -j n, --joystick n - Use joystick (n)");
LOG("\t-J s, --joystick s - Use joystick whose name contains (s)"); LOG(" -J s, --joystick s - Use joystick whose name contains (s)");
LOG("\t-m f, --music f - Set the music volume to f"); LOG(" -S, --Sound - Forces sound.");
LOG("\t-s f, --sound f - Set the sound volume to f"); LOG(" -m f --mvol f - Set the music volume to f");
LOG("\t-h --help - Display this message and exit."); LOG(" -s f --svol f - Set the sound volume to f");
LOG("\t-v - Print the version and exit"); LOG(" -h --help - Display this message and exit.");
LOG(" -v - Print the version and exit");
} }
// Set the default configuration. // Set the default configuration.
@ -79,6 +80,8 @@ void conf_setDefaults(void) {
gl_screen.w = 800; gl_screen.w = 800;
gl_screen.h = 640; gl_screen.h = 640;
gl_screen.flags = 0; gl_screen.flags = 0;
// Openal.
nosound = 1; // TODO: make sound default when it's sane again.
// Joystick. // Joystick.
indjoystick = -1; indjoystick = -1;
namjoystick = NULL; namjoystick = NULL;
@ -200,21 +203,22 @@ int conf_loadConfig(const char* file) {
// Parse some CLI options. // Parse some CLI options.
void conf_parseCLI(int argc, char** argv) { void conf_parseCLI(int argc, char** argv) {
static struct option long_options[] = { static struct option long_options[] = {
{ "fullscreen", no_argument, 0, 'f' }, { "fullscreen", no_argument, 0, 'f' },
{ "fps", required_argument, 0, 'F' }, { "fps", required_argument, 0, 'F' },
{ "data", required_argument, 0, 'd' }, { "data", required_argument, 0, 'd' },
{ "joystick", required_argument, 0, 'j' }, { "joystick", required_argument, 0, 'j' },
{ "Joystick", required_argument, 0, 'J' }, { "Joystick", required_argument, 0, 'J' },
{ "music", required_argument, 0, 'm' }, { "sound", no_argument, 0, 'S' },
{ "sound", required_argument, 0, 's' }, { "mvol", required_argument, 0, 'm' },
{ "help", no_argument, 0, 'h' }, { "svol", required_argument, 0, 's' },
{ "version", no_argument, 0, 'v' }, { "help", no_argument, 0, 'h' },
{ "version", no_argument, 0, 'v' },
{ NULL, 0, 0, 0 } { NULL, 0, 0, 0 }
}; };
int option_index = 0; int option_index = 0;
int c = 0; int c = 0;
while((c = getopt_long(argc, argv, "fF:d:J:j:s:m:V:hv", while((c = getopt_long(argc, argv, "fF:d:J:MSm:s:hv",
long_options, &option_index)) != -1) { long_options, &option_index)) != -1) {
switch(c) { switch(c) {
case 'f': case 'f':
@ -232,6 +236,12 @@ void conf_parseCLI(int argc, char** argv) {
case 'J': case 'J':
namjoystick = strdup(optarg); namjoystick = strdup(optarg);
break; break;
case 'M':
nosound = 1;
break;
case 'S':
nosound = 0;
break;
case 'm': case 'm':
music_volume(atof(optarg)); music_volume(atof(optarg));
break; break;