src/main.cpp

Sun, 08 Sep 2013 17:17:13 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sun, 08 Sep 2013 17:17:13 +0300
changeset 22
2fe0b7e0da7b
parent 20
a5457405cc9b
child 26
9aab482c9125
permissions
-rw-r--r--

For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.

13
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
1 /*
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
2 * ZanDemo: Zandronum demo launcher
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
3 * Copyright (C) 2013 Santeri Piippo
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
4 *
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
5 * This program is free software: you can redistribute it and/or modify
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
6 * it under the terms of the GNU General Public License as published by
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
8 * (at your option) any later version.
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
9 *
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
10 * This program is distributed in the hope that it will be useful,
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
13 * GNU General Public License for more details.
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
14 *
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
15 * You should have received a copy of the GNU General Public License
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
17 */
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
18
1
c9b22c06307c Done config box base
Teemu Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
19 #include <QApplication>
20
a5457405cc9b Use the cfg:: namespace system I made up a while ago instead of using QSettings directly, it's unsafe
Teemu Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
20 #include "config.h"
0
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include "types.h"
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
22 #include "demo.h"
0
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23
1
c9b22c06307c Done config box base
Teemu Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
24 // =============================================================================
c9b22c06307c Done config box base
Teemu Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
25 // -----------------------------------------------------------------------------
11
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
26 int main (int argc, char* argv[]) {
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
27 QApplication app (argc, argv);
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
28 app.setApplicationName (UNIXNAME);
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
29 app.setOrganizationName (UNIXNAME);
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
30 app.setApplicationVersion (versionString());
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
31
20
a5457405cc9b Use the cfg:: namespace system I made up a while ago instead of using QSettings directly, it's unsafe
Teemu Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
32 cfg::load();
a5457405cc9b Use the cfg:: namespace system I made up a while ago instead of using QSettings directly, it's unsafe
Teemu Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
33
11
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
34 for (int i = 1; i < argc; ++i) {
1
c9b22c06307c Done config box base
Teemu Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
35 str arg = argv[i];
c9b22c06307c Done config box base
Teemu Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
36
11
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
37 if (arg == "--config") {
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
38 ConfigBox dlg;
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
39 return dlg.exec();
1
c9b22c06307c Done config box base
Teemu Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
40 }
c9b22c06307c Done config box base
Teemu Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
41 }
c9b22c06307c Done config box base
Teemu Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
42
11
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
43 if (argc != 2) {
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
44 fprint (stderr, "Usage: %1 <demo> - Launch a demo file\n", argv[0]);
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
45 fprint (stderr, " %1 --config - Configure " APPNAME "\n", argv[0]);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
46 return 255;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
47 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
48
11
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
49 return launchDemo (argv[1]);
0
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 }
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51
1
c9b22c06307c Done config box base
Teemu Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
52 // =============================================================================
c9b22c06307c Done config box base
Teemu Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
53 // -----------------------------------------------------------------------------
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
54 str versionString() {
11
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
55 str text = fmt ("v%1.%2", VERSION_MAJOR, VERSION_MINOR);
0
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 #if VERSION_PATCH != 0
11
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
57 text += fmt (".%1", VERSION_PATCH);
0
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 #endif
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 #if BUILD_ID == BUILD_INTERNAL
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 text += "-intern";
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 #elif BUILD_ID == BUILD_ALPHA
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63 text += "-alpha";
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 #elif BUILD_ID == BUILD_BETA
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 text += "-beta";
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 #elif BUILD_ID == BUILD_RC
11
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
67 text += fmt ("-rc%1", RC_ID);
0
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 #elif BUILD_ID == BUILD_RELEASE
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 text += "-rel";
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 #else
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71 # error Invalid build code!
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 #endif // BUILD_ID
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73
bb264814dd81 Initial commit
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74 return text;
11
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
75 }

mercurial