src/demo.cpp

changeset 8
e8f645d9f28f
parent 6
67b6ef6917ba
child 10
bc1414343e19
equal deleted inserted replaced
7:fdabb5869e5f 8:e8f645d9f28f
3 #include <QMessageBox> 3 #include <QMessageBox>
4 #include <QProcess> 4 #include <QProcess>
5 #include "demo.h" 5 #include "demo.h"
6 #include "bytestream.h" 6 #include "bytestream.h"
7 #include "misc.h" 7 #include "misc.h"
8 #include "ui_demoprompt.h"
8 9
9 static const uint32 g_demoSignature = makeByteID( 'Z', 'C', 'L', 'D' ); 10 static const uint32 g_demoSignature = makeByteID( 'Z', 'C', 'L', 'D' );
10 11
11 // ============================================================================= 12 // =============================================================================
12 // ----------------------------------------------------------------------------- 13 // -----------------------------------------------------------------------------
130 s.readString( userinfo.skin ); 131 s.readString( userinfo.skin );
131 s.readLong( userinfo.railcolor ); 132 s.readLong( userinfo.railcolor );
132 s.readByte( userinfo.handicap ); 133 s.readByte( userinfo.handicap );
133 s.readByte( userinfo.unlagged ); 134 s.readByte( userinfo.unlagged );
134 s.readByte( userinfo.respawnOnFire ); 135 s.readByte( userinfo.respawnOnFire );
136 s.readByte( userinfo.ticsPerUpdate );
135 s.readByte( userinfo.connectionType ); 137 s.readByte( userinfo.connectionType );
136 s.readString( userinfo.className ); 138 s.readString( userinfo.className );
137 } elif( header == DemoWads + offset ) { 139 } elif( header == DemoWads + offset ) {
138 s.readShort( numWads ); 140 s.readShort( numWads );
139 141
171 if( binarypath.isEmpty() ) { 173 if( binarypath.isEmpty() ) {
172 error( fmt( tr( "No binary path specified for Zandronum version %1!\n" ), zanversion )); 174 error( fmt( tr( "No binary path specified for Zandronum version %1!\n" ), zanversion ));
173 return 7; 175 return 7;
174 } 176 }
175 177
176 str iwadpath; 178 str iwad, iwadpath;
177 list<str> pwadpaths; 179 list<str> pwads, pwadpaths;
178 180
179 // Find the WADs 181 // Find the WADs
180 for( const str& wad : wads ) { 182 for( const str& wad : wads ) {
181 str path = findWAD( wad ); 183 str path = findWAD( wad );
182 184
187 if( path.isEmpty() ) { 189 if( path.isEmpty() ) {
188 error( fmt( tr( "Couldn't find %1!\n" ), wad )); 190 error( fmt( tr( "Couldn't find %1!\n" ), wad ));
189 return 8; 191 return 8;
190 } 192 }
191 193
192 if( &wad == &wads[0] ) 194 if( &wad == &wads[0] ) {
193 iwadpath = path; 195 iwadpath = path;
194 else 196 iwad = wad;
197 } else {
195 pwadpaths << path; 198 pwadpaths << path;
199 pwads << wad;
200 }
201 }
202
203 if( !cfg.value( "nodemoprompt", false ).toBool() ) {
204 str pwadtext;
205 for( const str& pwad : pwads ) {
206 if( !pwadtext.isEmpty() )
207 pwadtext += "<br />";
208
209 pwadtext += pwad;
210 }
211
212 QDialog* dlg = new QDialog;
213 Ui_DemoPrompt ui;
214 ui.setupUi( dlg );
215 ui.demoNameLabel->setText( basename( path ));
216 ui.demoRecorder->setText( userinfo.netname );
217 ui.versionLabel->setText( zanversion );
218 ui.iwadLabel->setText( wads[0] );
219 ui.pwadsLabel->setText( pwadtext );
220
221 if( !dlg->exec() )
222 return 1;
196 } 223 }
197 224
198 print( "binary: %1\n", binarypath ); 225 print( "binary: %1\n", binarypath );
199 print( "iwad: %1\npwads: %2\n", iwadpath, pwadpaths ); 226 print( "iwad: %1\npwads: %2\n", iwadpath, pwadpaths );
200 227
201 QStringList cmdlineList ({ 228 QStringList cmdlineList ({
202 "-iwad", 229 "-playdemo", path,
203 iwadpath, 230 "-iwad", iwadpath,
204 "-playdemo",
205 path
206 }); 231 });
207 232
208 if( pwadpaths.size() > 0 ) { 233 if( pwadpaths.size() > 0 ) {
209 cmdlineList << "-file"; 234 cmdlineList << "-file";
210 cmdlineList << pwadpaths; 235 cmdlineList << pwadpaths;

mercurial