# HG changeset patch # User Teemu Piippo # Date 1374079486 -10800 # Node ID e8f645d9f28fc01def8a4b52ccb49f9714eea691 # Parent fdabb5869e5fa7e5667640722852bdd3ff6b2e75 Added a prompt for demo information diff -r fdabb5869e5f -r e8f645d9f28f src/config.cpp --- a/src/config.cpp Wed Jul 17 18:59:28 2013 +0300 +++ b/src/config.cpp Wed Jul 17 19:44:46 2013 +0300 @@ -74,6 +74,8 @@ int i = 0; for( str ver : g_zanVersions ) m_zanBinaries[i++]->setText( cfg.value( binaryConfigName( ver ), "" ).toString() ); + + ui->noDemoPrompt->setChecked( cfg.value( "nodemoprompt", false ).toBool() ); } // ============================================================================= @@ -139,6 +141,7 @@ wadPathList << ui->wad_pathsList->item( i )->text(); cfg.setValue( "wads/paths", wadPathList ); + cfg.setValue( "nodemoprompt", ui->noDemoPrompt->isChecked() ); int i = 0; for( str ver : g_zanVersions ) diff -r fdabb5869e5f -r e8f645d9f28f src/demo.cpp --- a/src/demo.cpp Wed Jul 17 18:59:28 2013 +0300 +++ b/src/demo.cpp Wed Jul 17 19:44:46 2013 +0300 @@ -5,6 +5,7 @@ #include "demo.h" #include "bytestream.h" #include "misc.h" +#include "ui_demoprompt.h" static const uint32 g_demoSignature = makeByteID( 'Z', 'C', 'L', 'D' ); @@ -132,6 +133,7 @@ s.readByte( userinfo.handicap ); s.readByte( userinfo.unlagged ); s.readByte( userinfo.respawnOnFire ); + s.readByte( userinfo.ticsPerUpdate ); s.readByte( userinfo.connectionType ); s.readString( userinfo.className ); } elif( header == DemoWads + offset ) { @@ -173,8 +175,8 @@ return 7; } - str iwadpath; - list pwadpaths; + str iwad, iwadpath; + list pwads, pwadpaths; // Find the WADs for( const str& wad : wads ) { @@ -189,20 +191,43 @@ return 8; } - if( &wad == &wads[0] ) + if( &wad == &wads[0] ) { iwadpath = path; - else + iwad = wad; + } else { pwadpaths << path; + pwads << wad; + } + } + + if( !cfg.value( "nodemoprompt", false ).toBool() ) { + str pwadtext; + for( const str& pwad : pwads ) { + if( !pwadtext.isEmpty() ) + pwadtext += "
"; + + pwadtext += pwad; + } + + QDialog* dlg = new QDialog; + Ui_DemoPrompt ui; + ui.setupUi( dlg ); + ui.demoNameLabel->setText( basename( path )); + ui.demoRecorder->setText( userinfo.netname ); + ui.versionLabel->setText( zanversion ); + ui.iwadLabel->setText( wads[0] ); + ui.pwadsLabel->setText( pwadtext ); + + if( !dlg->exec() ) + return 1; } print( "binary: %1\n", binarypath ); print( "iwad: %1\npwads: %2\n", iwadpath, pwadpaths ); QStringList cmdlineList ({ - "-iwad", - iwadpath, - "-playdemo", - path + "-playdemo", path, + "-iwad", iwadpath, }); if( pwadpaths.size() > 0 ) { diff -r fdabb5869e5f -r e8f645d9f28f src/misc.cpp --- a/src/misc.cpp Wed Jul 17 18:59:28 2013 +0300 +++ b/src/misc.cpp Wed Jul 17 19:44:46 2013 +0300 @@ -8,4 +8,15 @@ // ----------------------------------------------------------------------------- str binaryConfigName( str ver ) { return fmt( "binaries/%1", ver ); +} + +// ============================================================================= +// ----------------------------------------------------------------------------- +str basename( str path ) { + long lastpos = path.lastIndexOf( "/" ); + + if( lastpos != -1 ) + return path.mid( lastpos + 1 ); + + return path; } \ No newline at end of file diff -r fdabb5869e5f -r e8f645d9f28f src/misc.h --- a/src/misc.h Wed Jul 17 18:59:28 2013 +0300 +++ b/src/misc.h Wed Jul 17 19:44:46 2013 +0300 @@ -5,6 +5,7 @@ uint32 makeByteID( uint8 a, uint8 b, uint8 c, uint8 d ); str binaryConfigName( str ver ); +str basename( str path ); // ----------------------------------------------------------------------------- // Templated clamp diff -r fdabb5869e5f -r e8f645d9f28f src/ui/configbox.ui --- a/src/ui/configbox.ui Wed Jul 17 18:59:28 2013 +0300 +++ b/src/ui/configbox.ui Wed Jul 17 19:44:46 2013 +0300 @@ -128,8 +128,8 @@ 0 0 - 448 - 232 + 96 + 26 @@ -142,6 +142,36 @@ + + + Misc + + + + + + If this is not set, a prompt showing demo info is displayed first. + + + Launch immediately + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + diff -r fdabb5869e5f -r e8f645d9f28f src/ui/demoprompt.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui/demoprompt.ui Wed Jul 17 19:44:46 2013 +0300 @@ -0,0 +1,182 @@ + + + DemoPrompt + + + + 0 + 0 + 319 + 307 + + + + Dialog + + + + + + + 11 + 75 + false + true + + + + [[ DEMO NAME ]] + + + Qt::AlignCenter + + + + + + + + + Zandronum Version: + + + + + + + Recorder: + + + + + + + + 75 + true + + + + [[ VERSION ]] + + + + + + + + 75 + true + + + + [[ RECORDER ]] + + + + + + + IWAD: + + + + + + + + 75 + true + + + + [[ IWAD ]] + + + + + + + PWADs: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 75 + true + + + + [[ PWADS ]] + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + DemoPrompt + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DemoPrompt + reject() + + + 316 + 260 + + + 286 + 274 + + + + +