src/demo.cpp

Sun, 11 Aug 2013 03:06:54 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sun, 11 Aug 2013 03:06:54 +0300
changeset 13
9bdddd2ccde6
parent 11
3ddebf76105e
child 15
3d3e5f0fc4cc
permissions
-rw-r--r--

now with 3691% extra legalese!

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 "bytestream.h"
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 #include "misc.h"
8
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
26 #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
27 #include "prompts.h"
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
29 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
30
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 // =============================================================================
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 // -----------------------------------------------------------------------------
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
33 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
34 str out;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
35 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
36
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
37 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
38 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
39 continue;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
40
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
41 if (c.toAscii() == '\034') {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
42 skip = 1;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
43 continue;
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
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
46 out += c;
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 return out;
6
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 // =============================================================================
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 // -----------------------------------------------------------------------------
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
54 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
55 return QObject::tr (msg);
6
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 // =============================================================================
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 // -----------------------------------------------------------------------------
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
60 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
61 QMessageBox::critical (null, "Error", msg);
6
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 // =============================================================================
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 // -----------------------------------------------------------------------------
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
66 static bool isKnownVersion (str ver) {
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 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
68 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
69
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
70 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
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) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
80 QSettings cfg;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
81 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
82
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
83 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
84 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
85
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
86 // 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
87 // 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
88 exit (9);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
91 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
92 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
93 QFile f (fullpath);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
95 if (f.exists())
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 return fullpath;
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 return "";
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 // =============================================================================
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103 // -----------------------------------------------------------------------------
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
104 int launchDemo (str path) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
105 FILE* fp = fopen (path.toStdString().c_str(), "r");
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
106
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
107 if (!fp) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
108 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
109 return 1;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
110 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
112 fseek (fp, 0, SEEK_END);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
113 const size_t fsize = ftell (fp);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
114 rewind (fp);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
116 char* buf = new char[fsize];
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
118 if (fread (buf, 1, fsize, fp) != fsize) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
119 error (tr ("I/O error"));
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120 delete[] buf;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121 return 2;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 }
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
123
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
124 Bytestream s (buf, fsize);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125 delete[] buf;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
126
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
127 uint8 offset;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128 uint32 length;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 struct {
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131 str netname, skin, className;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 uint8 gender, handicap, unlagged, respawnOnFire, ticsPerUpdate, connectionType;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133 uint32 color, aimdist, railcolor;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
134 } userinfo;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
135
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136 // Check signature
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137 {
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138 uint32 sig;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
139
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
140 if (!s.readLong (sig) || sig != g_demoSignature) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
141 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
142 return 3;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146 // 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
147 // 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
148 // from this byte
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
149 s.readByte (offset);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
150 s.readLong (length);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
151
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
152 uint16 zanversionID, numWads;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
153 uint32 longSink;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
154 str zanversion;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
155 list<str> wads;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
156 bool ready = false;
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
157 uint8 buildID;
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
158
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
159 // 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
160 for (;;) {
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
161 uint8 header;
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
162
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
163 if (!s.readByte (header))
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
164 break;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
166 if (header == DemoBodyStart + offset) {
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
167 ready = true;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
168 break;
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
169 } elif (header == DemoVersion + offset) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
170 s.readShort (zanversionID);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
171 s.readString (zanversion);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
172
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
173 if (zanversion.left (4) != "1.1-" && zanversion.left (6) != "1.1.1-")
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
174 s.readByte (buildID);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
175 else
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
176 buildID = 1;
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
177
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
178 s.readLong (longSink); // rng seed - we don't need it
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
179 } elif (header == DemoUserInfo + offset) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
180 s.readString (userinfo.netname);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
181 s.readByte (userinfo.gender);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
182 s.readLong (userinfo.color);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
183 s.readLong (userinfo.aimdist);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
184 s.readString (userinfo.skin);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
185 s.readLong (userinfo.railcolor);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
186 s.readByte (userinfo.handicap);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
187 s.readByte (userinfo.unlagged);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
188 s.readByte (userinfo.respawnOnFire);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
189 s.readByte (userinfo.ticsPerUpdate);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
190 s.readByte (userinfo.connectionType);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
191 s.readString (userinfo.className);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
192 } 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
193 str sink;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
194 s.readShort (numWads);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
195
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
196 for (uint8 i = 0; i < numWads; ++i) {
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
197 str wad;
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
198 s.readString (wad);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
199 wads << wad;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
200 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
202 // The demo has two checksum strings. We're not interested
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
203 // in them though.
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
204 for (int i = 0; i < 2; ++i)
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
205 s.readString (sink);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
206 } else {
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
207 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
208 return 3;
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
209 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
210 }
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
211
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
212 if (!ready) {
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 ("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
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 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
218 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
219 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
220 return 6;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
221
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 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
224 return 6;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
225 }
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
226 }
11
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
227
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
228 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
229 str binarypath = cfg.value (binaryConfigName (zanversion)).toString();
11
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
230
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
231 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
232 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
233 return 7;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
234 }
11
3ddebf76105e made style more consistent
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
235
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
236 str iwadpath;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
237 list<str> pwadpaths;
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
238
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
239 // 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
240 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
241 str path = findWAD (wad);
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 // 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
244 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
245 path = findWAD (wad.toUpper());
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
246
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
247 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
248 error (fmt (tr ("Couldn't find %1!"), wad));
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
249 return 8;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
250 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
251
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
252 if (&wad == &wads[0])
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
253 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
254 else
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
255 pwadpaths << path;
8
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
256 }
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
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 (!cfg.value ("nodemoprompt", false).toBool()) {
8
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
259 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
260
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
261 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
262 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
263 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
264
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
265 if (!pwadtext.isEmpty())
8
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
266 pwadtext += "<br />";
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
267
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
268 pwadtext += pwad;
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
269 }
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
270
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
271 QDialog* dlg = new QDialog;
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
272 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
273 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
274 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
275 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
276 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
277 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
278 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
279 dlg->setWindowTitle (fmt (APPNAME " %1", versionString()));
8
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
280
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
281 if (!dlg->exec())
8
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
282 return 1;
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
283 }
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
284
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
285 QStringList cmdlineList ( {
8
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
286 "-playdemo", path,
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
287 "-iwad", iwadpath,
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
288 });
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 if (pwadpaths.size() > 0) {
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
291 cmdlineList << "-file";
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
292 cmdlineList << pwadpaths;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
293 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
294
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
295 print ("Executing: %1 %2\n", binarypath, cmdlineList.join (" "));
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
296 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
297 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
298 proc->waitForFinished (-1);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
299 return 0;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
300 }

mercurial