forked from mrkite/minutor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
104 lines (95 loc) · 2.75 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/** Copyright (c) 2013, Sean Kasun */
#include <QtWidgets/QApplication>
#include <QTranslator>
#include <QLocale>
#include "./minutor.h"
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QString locale = QLocale::system().name();
QTranslator translator;
translator.load(QString("minutor_")+locale);
app.installTranslator(&translator);
app.setApplicationName("Minutor");
app.setApplicationVersion("2.3.0");
app.setOrganizationName("seancode");
Minutor minutor;
// Process the cmdline arguments:
QStringList args = app.arguments();
int numArgs = args.size();
int ex_Xmin = 0;
int ex_Xmax = 0;
int ex_Zmin = 0;
int ex_Zmax = 0;
bool regionChecker = false;
bool chunkChecker = false;
for (int i = 0; i < numArgs; i++) {
if (args[i].length() > 2) {
// convert long variants to lower case
args[i] = args[i].toLower();
}
if ((args[i] == "-w" || args[i] == "--world") && i + 1 < numArgs) {
minutor.loadWorld(args[i + 1]);
i += 1;
continue;
}
if (args[i] == "--regionchecker") {
regionChecker = true;
continue;
}
if (args[i] == "--chunkchecker") {
chunkChecker = true;
continue;
}
if ((args[i] == "-r" || args[i] == "--exportrange") && i + 4 < numArgs) {
ex_Xmin = args[i + 1].toInt();
ex_Xmax = args[i + 2].toInt();
ex_Zmin = args[i + 3].toInt();
ex_Zmax = args[i + 4].toInt();
i += 4;
continue;
}
if ((args[i] == "-s" || args[i] == "--savepng") && i + 1 < numArgs) {
minutor.savePNG(args[i + 1], true, regionChecker, chunkChecker,
ex_Zmin, ex_Xmin, ex_Zmax, ex_Xmax);
i += 1;
continue;
}
if ((args[i] == "-j" || args[i] == "--jump") && i + 2 < numArgs) {
minutor.jumpToXZ(args[i + 1].toInt(), args[i + 2].toInt());
i += 2;
continue;
}
if ((args[i] == "-y" || args[i] == "--depth") && i + 1 < numArgs) {
minutor.setDepth(args[i + 1].toInt());
i += 1;
continue;
}
// menu View->
if (args[i] == "-L" || args[i] == "--lighting") {
minutor.setViewLighting(true);
continue;
}
if (args[i] == "-M" || args[i] == "--mobspawning") {
minutor.setViewMobspawning(true);
continue;
}
if (args[i] == "-D" || args[i] == "--depthshading") {
minutor.setViewDepthshading(true);
continue;
}
if (args[i] == "-B" || args[i] == "--biomecolors") {
minutor.setViewBiomeColors(true);
continue;
}
if (args[i] == "-C" || args[i] == "--cavemode") {
minutor.setViewCavemode(true);
continue;
}
if (args[i] == "-sl" || args[i] == "--singlelayer") {
minutor.setSingleLayer(true);
continue;
}
}
minutor.show();
return app.exec();
}