src/demo.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 21
99225eac33ba
child 23
3ce91eac0f24
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
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include <QFile>
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include <QDataStream>
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include <QMessageBox>
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include <QProcess>
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include "demo.h"
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 #include "misc.h"
8
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
25 #include "ui_demoprompt.h"
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
26 #include "prompts.h"
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27
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: 18
diff changeset
28 EXTERN_CONFIG (Map, binaryPaths)
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: 18
diff changeset
29 EXTERN_CONFIG (List, wadpaths)
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: 18
diff changeset
30 EXTERN_CONFIG (Bool, noprompt)
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: 18
diff changeset
31
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
32 static const uint32 g_demoSignature = makeByteID ('Z', 'C', 'L', 'D');
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 // =============================================================================
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 // -----------------------------------------------------------------------------
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
36 str uncolorize (const str& in) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
37 str out;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
38 int skip = 0;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
39
21
99225eac33ba use proper names QVariant and QChar instead of ambigous/dumb "var" and "qchar"
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
40 for (const QChar& c : in) {
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
41 if (skip-- > 0)
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
42 continue;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
43
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: 18
diff changeset
44 if (c == QChar ('\034')) {
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
45 skip = 1;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
46 continue;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
47 }
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
48
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
49 out += c;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
50 }
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
51
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
52 return out;
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 // =============================================================================
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 // -----------------------------------------------------------------------------
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
57 static str tr (const char* msg) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
58 return QObject::tr (msg);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 // =============================================================================
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 // -----------------------------------------------------------------------------
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
63 static void error (str msg) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
64 QMessageBox::critical (null, "Error", msg);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 // =============================================================================
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 // -----------------------------------------------------------------------------
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
69 static bool isKnownVersion (str ver) {
21
99225eac33ba use proper names QVariant and QChar instead of ambigous/dumb "var" and "qchar"
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
70 for (const QVariant& it : getVersions())
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
71 if (it.toString() == ver || it.toString() + 'M' == ver)
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
72 return true;
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
74 return false;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
75 }
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
76
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
77 // =============================================================================
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
78 // -----------------------------------------------------------------------------
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
79 static str findWAD (str name) {
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: 18
diff changeset
80 if (cfg::wadpaths.size() == 0) {
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
81 error (tr ("No WAD paths configured!"));
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
82
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
83 // Cannot just return an empty string here since that'd trigger
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
84 // another error prompt - skip ahead and exit.
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
85 exit (9);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87
21
99225eac33ba use proper names QVariant and QChar instead of ambigous/dumb "var" and "qchar"
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
88 for (const QVariant& it : cfg::wadpaths) {
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
89 str fullpath = fmt ("%1/%2", it.toString(), name);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
90 QFile f (fullpath);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
92 if (f.exists())
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 return fullpath;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 return "";
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99 // =============================================================================
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100 // -----------------------------------------------------------------------------
22
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
101 str readString (QDataStream& stream) {
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
102 str out;
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
103 uint8 c;
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
104
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
105 for (stream >> c; c != '\0'; stream >> c)
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
106 out += c;
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
107
22
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
108 return out;
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
109 }
15
3d3e5f0fc4cc made it compile on windows/qt5
Teemu Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
110
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
111 // =============================================================================
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
112 // -----------------------------------------------------------------------------
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
113 int launchDemo (str path) {
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
114 QFile f (path);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
116 if (!f.open (QIODevice::ReadOnly)) {
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
117 error (fmt (tr ("Couldn't open '%1' for reading: %2"), path, strerror (errno)));
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
118 return 1;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
121 QDataStream stream (&f);
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
122 stream.setByteOrder (QDataStream::LittleEndian);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
123
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124 uint8 offset;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125 uint32 length;
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
126 uint16 zanversionID, numWads;
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
127 uint32 longSink;
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
128 str zanversion;
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
129 list<str> wads;
22
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
130 BuildType buildID;
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
131 bool ready = false;
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133 struct {
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
134 str netname, skin, className;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
135 uint8 gender, handicap, unlagged, respawnOnFire, ticsPerUpdate, connectionType;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136 uint32 color, aimdist, railcolor;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137 } userinfo;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
139 // Check signature
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
140 {
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
141 uint32 sig;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
143 stream >> sig;
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
144 if (sig != g_demoSignature) {
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
145 error (fmt (tr ("'%1' is not a Zandronum demo file!"), path));
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146 return 3;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
148 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
149
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
150 // Zandronum stores CLD_DEMOLENGTH after the signature. This is also the
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151 // first demo enumerator, so we can determine the offset (which is variable!)
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
152 // from this byte
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
153 stream >> offset
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
154 >> length;
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
155
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
156 // Read the demo header and get data
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
157 for (;;) {
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
158 uint8 header;
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
159 stream >> header;
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
160 print ("header: %1\n", (int) header);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
161
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
162 if (header == DemoBodyStart + offset) {
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
163 ready = true;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
164 break;
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
165 } elif (header == DemoVersion + offset) {
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
166 print ("Read demo version\n");
22
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
167 stream >> zanversionID;
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
168 zanversion = readString (stream);
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
169
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
170 print ("version ID: %1, version: %2\n", zanversionID, zanversion);
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
171
22
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
172 if (!zanversion.startsWith ("1.1-") && !zanversion.startsWith ("1.1.1-")) {
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
173 uint8 a;
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
174 stream >> a;
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
175 buildID = (BuildType) a;
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
176 } else {
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
177 // Assume a release build if not supplied. The demo only got the
22
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
178 // "ZCLD" signature in the 1.1 release build, 1.1.1 had no testing
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
179 // binaries and the build ID is included in 1.2 onward.
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
180 buildID = ReleaseBuild;
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
181 }
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
182
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
183 stream >> longSink; // rng seed - we don't need it
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
184 } elif (header == DemoUserInfo + offset) {
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
185 print ("Read userinfo\n");
22
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
186 userinfo.netname = readString (stream);
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
187 stream >> userinfo.gender
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
188 >> userinfo.color
22
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
189 >> userinfo.aimdist;
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
190 userinfo.skin = readString (stream);
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
191 stream >> userinfo.railcolor
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
192 >> userinfo.handicap
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
193 >> userinfo.unlagged
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
194 >> userinfo.respawnOnFire
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
195 >> userinfo.ticsPerUpdate
22
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
196 >> userinfo.connectionType;
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
197 userinfo.className = readString (stream);
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
198 } elif (header == DemoWads + offset) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
199 str sink;
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
200 stream >> numWads;
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
201
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
202 for (uint8 i = 0; i < numWads; ++i) {
22
2fe0b7e0da7b For some God-knows-why reason, adding operator>> overloads to QDataStream leads into crashes with QFileDialog. Fixed by removing these overloads.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
203 str wad = readString (stream);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
204 wads << wad;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
205 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
206
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
207 // The demo has two checksum strings. We're not interested
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
208 // in them though. Down the sink they go...
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
209 for (int i = 0; i < 2; ++i)
18
6bf57b4f42cd Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
210 stream >> sink;
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211 } else {
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
212 error (fmt (tr ("Unknown header %1!\n"), (int) header));
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
213 return 3;
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
214 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
215 }
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
216
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
217 if (!ready) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
218 error (fmt (tr ("Incomplete demo header in '%s'!"), path));
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
219 return 3;
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
220 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
221
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
222 if (!isKnownVersion (zanversion)) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
223 UnknownVersionPrompt* prompt = new UnknownVersionPrompt (path, zanversion, (buildID == 1));
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
224 if (!prompt->exec())
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
225 return 6;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
226
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
227 if (!isKnownVersion (zanversion)) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
228 error (tr ("Failure in configuration! This shouldn't happen."));
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
229 return 6;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
230 }
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
231 }
11
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
232
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: 18
diff changeset
233 str binarypath = cfg::binaryPaths [zanversion].toString();
11
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
234
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
235 if (binarypath.isEmpty()) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
236 error (fmt (tr ("No binary path specified for Zandronum version %1!"), zanversion));
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
237 return 7;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
238 }
11
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
239
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
240 str iwadpath;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
241 list<str> pwadpaths;
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
242
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
243 // Find the WADs
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
244 for (const str& wad : wads) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
245 str path = findWAD (wad);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
246
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
247 // IWAD names can appear in uppercase too. Linux is case-sensitive, so..
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
248 if (&wad == &wads[0] && path.isEmpty())
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
249 path = findWAD (wad.toUpper());
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
250
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
251 if (path.isEmpty()) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
252 error (fmt (tr ("Couldn't find %1!"), wad));
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
253 return 8;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
254 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
255
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
256 if (&wad == &wads[0])
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
257 iwadpath = path;
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
258 else
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
259 pwadpaths << path;
8
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
260 }
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
261
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: 18
diff changeset
262 if (!cfg::noprompt) {
8
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
263 str pwadtext;
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
264
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
265 for (const str& pwad : wads) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
266 if (&pwad == &wads[0])
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
267 continue; // skip the IWAD
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
268
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
269 if (!pwadtext.isEmpty())
8
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
270 pwadtext += "<br />";
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
271
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
272 pwadtext += pwad;
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
273 }
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
274
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
275 QDialog* dlg = new QDialog;
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
276 Ui_DemoPrompt ui;
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
277 ui.setupUi (dlg);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
278 ui.demoNameLabel->setText (basename (path));
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
279 ui.demoRecorder->setText (uncolorize (userinfo.netname));
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
280 ui.versionLabel->setText (zanversion);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
281 ui.iwadLabel->setText (wads[0]);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
282 ui.pwadsLabel->setText (pwadtext);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
283 dlg->setWindowTitle (fmt (APPNAME " %1", versionString()));
8
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
284
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
285 if (!dlg->exec())
8
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
286 return 1;
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
287 }
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
288
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: 18
diff changeset
289 QStringList cmdlineList ({
8
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
290 "-playdemo", path,
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
291 "-iwad", iwadpath,
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
292 });
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
293
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
294 if (pwadpaths.size() > 0) {
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
295 cmdlineList << "-file";
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
296 cmdlineList << pwadpaths;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
297 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
298
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
299 print ("Executing: %1 %2\n", binarypath, cmdlineList.join (" "));
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
300 QProcess* proc = new QProcess;
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
301 proc->start (binarypath, cmdlineList);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
302 proc->waitForFinished (-1);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
303 return 0;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
304 }

mercurial