|
| 1 | +#include <cstdio> |
1 | 2 | #include <cstdlib>
|
2 | 3 | #include <cstring>
|
3 | 4 | #include <getopt.h>
|
4 | 5 | #include <fstream>
|
5 | 6 | #include <iostream>
|
6 |
| -#include <map> |
| 7 | +#include <utility> |
7 | 8 | #include <string>
|
8 | 9 | #include <sstream>
|
9 | 10 | #include <stdexcept>
|
|
12 | 13 |
|
13 | 14 | static void usage()
|
14 | 15 | {
|
15 |
| - const char *usage_text = "minetestmapper [options]\n" |
16 |
| - " -i/--input <world_path>\n" |
17 |
| - " -o/--output <output_image.png>\n" |
18 |
| - " --bgcolor <color>\n" |
19 |
| - " --scalecolor <color>\n" |
20 |
| - " --playercolor <color>\n" |
21 |
| - " --origincolor <color>\n" |
22 |
| - " --drawscale\n" |
23 |
| - " --drawplayers\n" |
24 |
| - " --draworigin\n" |
25 |
| - " --drawalpha\n" |
26 |
| - " --noshading\n" |
27 |
| - " --noemptyimage\n" |
28 |
| - " --min-y <y>\n" |
29 |
| - " --max-y <y>\n" |
30 |
| - " --backend <backend>\n" |
31 |
| - " --geometry x:y+w+h\n" |
32 |
| - " --extent\n" |
33 |
| - " --zoom <zoomlevel>\n" |
34 |
| - " --colors <colors.txt>\n" |
35 |
| - " --scales [t][b][l][r]\n" |
36 |
| - " --exhaustive never|y|full|auto\n" |
37 |
| - "Color format: '#000000'\n"; |
38 |
| - std::cout << usage_text; |
| 16 | + const std::pair<const char*, const char*> options[] = { |
| 17 | + {"-i/--input", "<world_path>"}, |
| 18 | + {"-o/--output", "<output_image.png>"}, |
| 19 | + {"--bgcolor", "<color>"}, |
| 20 | + {"--scalecolor", "<color>"}, |
| 21 | + {"--playercolor", "<color>"}, |
| 22 | + {"--origincolor", "<color>"}, |
| 23 | + {"--drawscale", ""}, |
| 24 | + {"--drawplayers", ""}, |
| 25 | + {"--draworigin", ""}, |
| 26 | + {"--drawalpha", ""}, |
| 27 | + {"--noshading", ""}, |
| 28 | + {"--noemptyimage", ""}, |
| 29 | + {"--min-y", "<y>"}, |
| 30 | + {"--max-y", "<y>"}, |
| 31 | + {"--backend", "<backend>"}, |
| 32 | + {"--geometry", "x:y+w+h"}, |
| 33 | + {"--extent", ""}, |
| 34 | + {"--zoom", "<zoomlevel>"}, |
| 35 | + {"--colors", "<colors.txt>"}, |
| 36 | + {"--scales", "[t][b][l][r]"}, |
| 37 | + {"--exhaustive", "never|y|full|auto"}, |
| 38 | + }; |
| 39 | + const char *top_text = |
| 40 | + "minetestmapper -i <world_path> -o <output_image.png> [options]\n" |
| 41 | + "Generate an overview image of a Minetest map.\n" |
| 42 | + "\n" |
| 43 | + "Options:\n"; |
| 44 | + const char *bottom_text = |
| 45 | + "\n" |
| 46 | + "Color format: hexadecimal '#RRGGBB', e.g. '#FF0000' = red\n"; |
| 47 | + |
| 48 | + printf("%s", top_text); |
| 49 | + for (const auto &p : options) |
| 50 | + printf(" %-18s%s\n", p.first, p.second); |
| 51 | + printf("%s", bottom_text); |
| 52 | + auto backends = TileGenerator::getSupportedBackends(); |
| 53 | + printf("Supported backends: "); |
| 54 | + for (auto s : backends) |
| 55 | + printf("%s ", s.c_str()); |
| 56 | + printf("\n"); |
39 | 57 | }
|
40 | 58 |
|
41 | 59 | static bool file_exists(const std::string &path)
|
|
0 commit comments