rev |
line source |
nuclear@18
|
1 #include <stdio.h>
|
nuclear@18
|
2 #include <stdlib.h>
|
nuclear@18
|
3 #include <string.h>
|
nuclear@18
|
4 #include "cfg.h"
|
nuclear@18
|
5
|
nuclear@18
|
6 Config cfg;
|
nuclear@18
|
7
|
nuclear@18
|
8 Config::Config()
|
nuclear@18
|
9 {
|
nuclear@18
|
10 width = 800;
|
nuclear@18
|
11 height = 600;
|
nuclear@18
|
12 stereo = false;
|
nuclear@47
|
13 sound = true;
|
nuclear@18
|
14 level_file = "0.level";
|
nuclear@18
|
15 tileset_file = "default.tileset";
|
nuclear@42
|
16 use_deferred = true;
|
nuclear@18
|
17 }
|
nuclear@18
|
18
|
nuclear@18
|
19 bool Config::parse_args(int argc, char **argv)
|
nuclear@18
|
20 {
|
nuclear@18
|
21 for(int i=1; i<argc; i++) {
|
nuclear@25
|
22 if(argv[i][0] == '-') {
|
nuclear@25
|
23 if(strcmp(argv[i], "-s") == 0) {
|
nuclear@25
|
24 if(sscanf(argv[++i], "%dx%d", &width, &height) != 2) {
|
nuclear@25
|
25 fprintf(stderr, "-s must be followed by <width>x<height>\n");
|
nuclear@25
|
26 return false;
|
nuclear@25
|
27 }
|
nuclear@25
|
28 } else if(strcmp(argv[i], "-stereo") == 0) {
|
nuclear@25
|
29 stereo = true;
|
nuclear@47
|
30 } else if(strcmp(argv[i], "-nosound") == 0) {
|
nuclear@47
|
31 sound = false;
|
nuclear@25
|
32 } else if(strcmp(argv[i], "-level") == 0) {
|
nuclear@25
|
33 level_file = argv[++i];
|
nuclear@25
|
34 } else if(strcmp(argv[i], "-tileset") == 0) {
|
nuclear@25
|
35 tileset_file = argv[++i];
|
nuclear@42
|
36 } else if(strcmp(argv[i], "-no-deferred") == 0) {
|
nuclear@42
|
37 use_deferred = false;
|
nuclear@25
|
38 } else if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0) {
|
nuclear@25
|
39 printf("Usage: %s [options]\n", argv[0]);
|
nuclear@25
|
40 printf(" -s WxH window size (resolution)\n");
|
nuclear@25
|
41 printf(" -level <filename> specify which level file to load\n");
|
nuclear@25
|
42 printf(" -tileset <filename> specify which tileset to use\n");
|
nuclear@25
|
43 printf(" -stereo enable stereoscopic rendering\n");
|
nuclear@47
|
44 printf(" -nosound disable sound output\n");
|
nuclear@42
|
45 printf(" -no-deferred disable deferred renderer\n");
|
nuclear@25
|
46 printf(" -h/-help print usage information and exit\n");
|
nuclear@25
|
47 exit(0);
|
nuclear@25
|
48
|
nuclear@25
|
49 } else {
|
nuclear@25
|
50 fprintf(stderr, "unrecognized option: %s\n", argv[i]);
|
nuclear@18
|
51 return false;
|
nuclear@18
|
52 }
|
nuclear@18
|
53 } else {
|
nuclear@25
|
54 level_file = argv[i];
|
nuclear@18
|
55 }
|
nuclear@18
|
56 }
|
nuclear@18
|
57 return true;
|
nuclear@18
|
58 }
|