Added --geometry support.

This commit is contained in:
Miroslav Bendík
2012-11-24 19:25:13 +01:00
parent 5969c61e54
commit 7d15dbf4ed
4 changed files with 64 additions and 1 deletions

View File

@ -12,6 +12,7 @@
#include <iostream>
#include <map>
#include <string>
#include <sstream>
#include "TileGenerator.h"
using namespace std;
@ -28,6 +29,7 @@ void usage()
--drawscale\n\
--drawplayers\n\
--draworigin\n\
--geometry x:y+w+h\n\
Color format: '#000000'\n";
std::cout << usage_text;
}
@ -46,6 +48,7 @@ int main(int argc, char *argv[])
{"draworigin", no_argument, 0, 'R'},
{"drawplayers", no_argument, 0, 'P'},
{"drawscale", no_argument, 0, 'S'},
{"geometry", required_argument, 0, 'g'},
};
string input;
@ -96,6 +99,19 @@ int main(int argc, char *argv[])
case 'S':
generator.setDrawScale(true);
break;
case 'g': {
istringstream geometry;
geometry.str(optarg);
int x, y, w, h;
char c;
geometry >> x >> c >> y >> w >> h;
if (geometry.fail() || c != ':' || w < 1 || h < 1) {
usage();
exit(-1);
}
generator.setGeometry(x, y, w, h);
}
break;
default:
abort();
}