dungeon_crawler

view prototype/src/cfg.cc @ 42:6d71dd4760f9

added flag to force the use of the fallback renderer
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 30 Aug 2012 05:38:03 +0300
parents 527fede30057
children d52711f2b9a1
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 level_file = "0.level";
14 tileset_file = "default.tileset";
15 use_deferred = true;
16 }
18 bool Config::parse_args(int argc, char **argv)
19 {
20 for(int i=1; i<argc; i++) {
21 if(argv[i][0] == '-') {
22 if(strcmp(argv[i], "-s") == 0) {
23 if(sscanf(argv[++i], "%dx%d", &width, &height) != 2) {
24 fprintf(stderr, "-s must be followed by <width>x<height>\n");
25 return false;
26 }
27 } else if(strcmp(argv[i], "-stereo") == 0) {
28 stereo = true;
29 } else if(strcmp(argv[i], "-level") == 0) {
30 level_file = argv[++i];
31 } else if(strcmp(argv[i], "-tileset") == 0) {
32 tileset_file = argv[++i];
33 } else if(strcmp(argv[i], "-no-deferred") == 0) {
34 use_deferred = false;
35 } else if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0) {
36 printf("Usage: %s [options]\n", argv[0]);
37 printf(" -s WxH window size (resolution)\n");
38 printf(" -level <filename> specify which level file to load\n");
39 printf(" -tileset <filename> specify which tileset to use\n");
40 printf(" -stereo enable stereoscopic rendering\n");
41 printf(" -no-deferred disable deferred renderer\n");
42 printf(" -h/-help print usage information and exit\n");
43 exit(0);
45 } else {
46 fprintf(stderr, "unrecognized option: %s\n", argv[i]);
47 return false;
48 }
49 } else {
50 level_file = argv[i];
51 }
52 }
53 return true;
54 }