1
- /*
2
- * =====================================================================
3
- * Version: 1.0
4
- * Created: 22.08.2012 15:15:54
5
- * Author: Miroslav Bendík
6
- * Company: LinuxOS.sk
7
- * =====================================================================
8
- */
9
-
10
1
#include < cstdlib>
11
2
#include < getopt.h>
12
3
#include < iostream>
16
7
#include < stdexcept>
17
8
#include " TileGenerator.h"
18
9
19
- using namespace std ;
20
-
21
10
void usage ()
22
11
{
23
12
const char *usage_text = " minetestmapper [options]\n "
@@ -37,10 +26,17 @@ void usage()
37
26
" --backend <backend>\n "
38
27
" --geometry x:y+w+h\n "
39
28
" --zoom <zoomlevel>\n "
29
+ " --colors <colors.txt>\n "
40
30
" Color format: '#000000'\n " ;
41
31
std::cout << usage_text;
42
32
}
43
33
34
+ std::string search_colors ()
35
+ {
36
+ // TBD
37
+ return " colors.txt" ;
38
+ }
39
+
44
40
int main (int argc, char *argv[])
45
41
{
46
42
static struct option long_options[] =
@@ -61,14 +57,15 @@ int main(int argc, char *argv[])
61
57
{" geometry" , required_argument, 0 , ' g' },
62
58
{" min-y" , required_argument, 0 , ' a' },
63
59
{" max-y" , required_argument, 0 , ' c' },
64
- {" zoom" , required_argument, 0 , ' z' }
60
+ {" zoom" , required_argument, 0 , ' z' },
61
+ {" colors" , required_argument, 0 , ' C' },
65
62
};
66
63
67
- string input;
68
- string output;
64
+ std::string input;
65
+ std::string output;
66
+ std::string colors = " " ;
69
67
70
68
TileGenerator generator;
71
- generator.parseColorsFile (" colors.txt" );
72
69
int option_index = 0 ;
73
70
int c = 0 ;
74
71
while (1 ) {
@@ -122,23 +119,23 @@ int main(int argc, char *argv[])
122
119
generator.setBackend (optarg );
123
120
break ;
124
121
case ' a' : {
125
- istringstream iss;
122
+ std:: istringstream iss;
126
123
iss.str (optarg );
127
124
int miny;
128
125
iss >> miny;
129
126
generator.setMinY (miny);
130
127
}
131
128
break ;
132
129
case ' c' : {
133
- istringstream iss;
130
+ std:: istringstream iss;
134
131
iss.str (optarg );
135
132
int maxy;
136
133
iss >> maxy;
137
134
generator.setMaxY (maxy);
138
135
}
139
136
break ;
140
137
case ' g' : {
141
- istringstream geometry;
138
+ std:: istringstream geometry;
142
139
geometry.str (optarg );
143
140
int x, y, w, h;
144
141
char c;
@@ -151,21 +148,27 @@ int main(int argc, char *argv[])
151
148
}
152
149
break ;
153
150
case ' z' : {
154
- istringstream iss;
151
+ std:: istringstream iss;
155
152
iss.str (optarg );
156
153
int zoom;
157
154
iss >> zoom;
158
155
generator.setZoom (zoom);
159
156
}
160
157
break ;
158
+ case ' C' :
159
+ colors = optarg ;
160
+ break ;
161
161
default :
162
162
exit (1 );
163
163
}
164
164
}
165
+ if (colors == " " )
166
+ colors = search_colors ();
165
167
try {
168
+ generator.parseColorsFile (colors);
166
169
generator.generate (input, output);
167
170
} catch (std::runtime_error e) {
168
- std::cout<< " Exception: " << e.what ()<< std::endl;
171
+ std::cerr << " Exception: " << e.what () << std::endl;
169
172
return 1 ;
170
173
}
171
174
return 0 ;
0 commit comments