Sun, 11 Aug 2013 16:08:13 +0300
Added infurnus' application icon
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 | |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
28 | 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
|
29 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | // ============================================================================= |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
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 | 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
|
33 | str out; |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
34 | 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
|
35 | |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
36 | for (const qchar& c : in) { |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
37 | 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
|
38 | continue; |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
39 | |
17
b41d74bacdea
Qt4 has QChar::toLatin1() as well so we don't need to use toAscii() in Qt4.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
40 | if (c.toLatin1() == '\034') { |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
41 | skip = 1; |
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 | } |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
44 | |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
45 | out += c; |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
46 | } |
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 | return out; |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | } |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | // ============================================================================= |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | // ----------------------------------------------------------------------------- |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
53 | 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
|
54 | return QObject::tr (msg); |
6
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 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | // ============================================================================= |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | // ----------------------------------------------------------------------------- |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
59 | 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
|
60 | QMessageBox::critical (null, "Error", msg); |
6
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 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | // ============================================================================= |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | // ----------------------------------------------------------------------------- |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
65 | static bool isKnownVersion (str ver) { |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | QSettings cfg; |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
67 | list<var> versions = getVersionsList(); |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
68 | |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
69 | for (const var& it : versions) |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
70 | 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
|
71 | return true; |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
73 | return false; |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
74 | } |
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 | static str findWAD (str name) { |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
79 | QSettings cfg; |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
80 | list<var> paths = cfg.value ("wads/paths", list<var>()).toList(); |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
81 | |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
82 | if (paths.size() == 0) { |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
83 | 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
|
84 | |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
85 | // 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
|
86 | // 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
|
87 | exit (9); |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | } |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
90 | for (const var& it : paths) { |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
91 | 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
|
92 | QFile f (fullpath); |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
94 | if (f.exists()) |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | return fullpath; |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | } |
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 | return ""; |
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 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | // ============================================================================= |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | // ----------------------------------------------------------------------------- |
18
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
103 | QDataStream& operator>> (QDataStream& stream, str& out) { |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
104 | uint8 c; |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
105 | out = ""; |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
106 | |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
107 | for (stream >> c; c != '\0'; stream >> c) |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
108 | out += c; |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
109 | |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
110 | return stream; |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
111 | } |
15
3d3e5f0fc4cc
made it compile on windows/qt5
Teemu Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
112 | |
18
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
113 | // ============================================================================= |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
114 | // ----------------------------------------------------------------------------- |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
115 | int launchDemo (str path) { |
18
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
116 | QFile f (path); |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | |
18
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
118 | 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
|
119 | 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
|
120 | return 1; |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | } |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | |
18
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
123 | QDataStream stream (&f); |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
124 | stream.setByteOrder (QDataStream::LittleEndian); |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
125 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
126 | uint8 offset; |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | uint32 length; |
18
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
128 | uint16 zanversionID, numWads; |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
129 | uint32 longSink; |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
130 | str zanversion; |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
131 | list<str> wads; |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
132 | uint8 buildID; |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
133 | bool ready = false; |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | struct { |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
136 | str netname, skin, className; |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
137 | uint8 gender, handicap, unlagged, respawnOnFire, ticsPerUpdate, connectionType; |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
138 | uint32 color, aimdist, railcolor; |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
139 | } userinfo; |
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 | // Check signature |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
142 | { |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | uint32 sig; |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | |
18
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
145 | stream >> sig; |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
146 | 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
|
147 | 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
|
148 | return 3; |
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 | } |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
152 | // 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
|
153 | // 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
|
154 | // from this byte |
18
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
155 | stream >> offset |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
156 | >> length; |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
157 | |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
158 | // 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
|
159 | for (;;) { |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
160 | uint8 header; |
18
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
161 | stream >> header; |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
162 | print ("header: %1\n", (int) header); |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
163 | |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
164 | if (header == DemoBodyStart + offset) { |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
165 | ready = true; |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
166 | break; |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
167 | } elif (header == DemoVersion + offset) { |
18
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
168 | print ("Read demo version\n"); |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
169 | stream >> zanversionID |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
170 | >> zanversion; |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
171 | |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
172 | 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
|
173 | |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
174 | if (zanversion.left (4) != "1.1-" && zanversion.left (6) != "1.1.1-") |
18
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
175 | stream >> buildID; |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
176 | else { |
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 |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
178 | // "ZCLD" signature in the 1.1 release build, 1.1.1 had no |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
179 | // development binaries and the build ID will be included in 1.1.2. |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
180 | buildID = 1; |
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"); |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
186 | stream >> userinfo.netname |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
187 | >> userinfo.gender |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
188 | >> userinfo.color |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
189 | >> userinfo.aimdist |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
190 | >> userinfo.skin |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
191 | >> userinfo.railcolor |
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 |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
196 | >> userinfo.connectionType |
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
197 | >> userinfo.className; |
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) { |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
203 | str wad; |
18
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
204 | stream >> wad; |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
205 | wads << wad; |
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 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
208 | // 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
|
209 | // 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
|
210 | for (int i = 0; i < 2; ++i) |
18
6bf57b4f42cd
Replaced the Bytestream class with QDataStream
Teemu Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
211 | stream >> sink; |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
212 | } else { |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
213 | 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
|
214 | return 3; |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
215 | } |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
216 | } |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
217 | |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
218 | if (!ready) { |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
219 | 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
|
220 | return 3; |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
221 | } |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
222 | |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
223 | 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
|
224 | 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
|
225 | 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
|
226 | return 6; |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
227 | |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
228 | 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
|
229 | 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
|
230 | return 6; |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
231 | } |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
232 | } |
11
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
233 | |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
234 | QSettings cfg; |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
235 | str binarypath = cfg.value (binaryConfigName (zanversion)).toString(); |
11
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
236 | |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
237 | 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
|
238 | 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
|
239 | return 7; |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
240 | } |
11
3ddebf76105e
made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
241 | |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
242 | str iwadpath; |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
243 | list<str> pwadpaths; |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
244 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
245 | // 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
|
246 | 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
|
247 | str path = findWAD (wad); |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
248 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
249 | // 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
|
250 | 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
|
251 | path = findWAD (wad.toUpper()); |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
252 | |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
253 | 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
|
254 | error (fmt (tr ("Couldn't find %1!"), wad)); |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
255 | return 8; |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
256 | } |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
257 | |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
258 | if (&wad == &wads[0]) |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
259 | 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
|
260 | else |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
261 | pwadpaths << path; |
8
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
262 | } |
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
263 | |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
264 | if (!cfg.value ("nodemoprompt", false).toBool()) { |
8
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
265 | 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
|
266 | |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
267 | 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
|
268 | 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
|
269 | 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
|
270 | |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
271 | if (!pwadtext.isEmpty()) |
8
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
272 | pwadtext += "<br />"; |
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 | pwadtext += pwad; |
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
275 | } |
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
276 | |
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
277 | QDialog* dlg = new QDialog; |
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
278 | 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
|
279 | 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
|
280 | 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
|
281 | 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
|
282 | 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
|
283 | 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
|
284 | 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
|
285 | dlg->setWindowTitle (fmt (APPNAME " %1", versionString())); |
8
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
286 | |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
287 | if (!dlg->exec()) |
8
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
288 | return 1; |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
289 | } |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
290 | |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
291 | QStringList cmdlineList ( { |
8
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
292 | "-playdemo", path, |
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
293 | "-iwad", iwadpath, |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
294 | }); |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
295 | |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
296 | if (pwadpaths.size() > 0) { |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
297 | cmdlineList << "-file"; |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
298 | cmdlineList << pwadpaths; |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
299 | } |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
300 | |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
301 | print ("Executing: %1 %2\n", binarypath, cmdlineList.join (" ")); |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
302 | 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
|
303 | 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
|
304 | proc->waitForFinished (-1); |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
305 | return 0; |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
306 | } |