dungeon_crawler

view prototype/src/cfg.cc @ 53:1ea56011c1ff

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