Wed, 17 Jul 2013 19:44:46 +0300
Added a prompt for demo information
src/config.cpp | file | annotate | diff | comparison | revisions | |
src/demo.cpp | file | annotate | diff | comparison | revisions | |
src/misc.cpp | file | annotate | diff | comparison | revisions | |
src/misc.h | file | annotate | diff | comparison | revisions | |
src/ui/configbox.ui | file | annotate | diff | comparison | revisions | |
src/ui/demoprompt.ui | file | annotate | diff | comparison | revisions |
--- 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 )
--- 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<str> pwadpaths; + str iwad, iwadpath; + list<str> 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 += "<br />"; + + 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 ) {
--- 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
--- 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
--- 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 @@ <rect> <x>0</x> <y>0</y> - <width>448</width> - <height>232</height> + <width>96</width> + <height>26</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_5"> @@ -142,6 +142,36 @@ </item> </layout> </widget> + <widget class="QWidget" name="tab_3"> + <attribute name="title"> + <string>Misc</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_6"> + <item> + <widget class="QCheckBox" name="noDemoPrompt"> + <property name="whatsThis"> + <string>If this is not set, a prompt showing demo info is displayed first.</string> + </property> + <property name="text"> + <string>Launch immediately</string> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> </widget> </item> <item>
--- /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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>DemoPrompt</class> + <widget class="QDialog" name="DemoPrompt"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>319</width> + <height>307</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="demoNameLabel"> + <property name="font"> + <font> + <pointsize>11</pointsize> + <weight>75</weight> + <italic>false</italic> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>[[ DEMO NAME ]]</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <layout class="QFormLayout" name="formLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Zandronum Version:</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Recorder:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="versionLabel"> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>[[ VERSION ]]</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="demoRecorder"> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>[[ RECORDER ]]</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>IWAD:</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLabel" name="iwadLabel"> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>[[ IWAD ]]</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>PWADs:</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QLabel" name="pwadsLabel"> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>[[ PWADS ]]</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>DemoPrompt</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>DemoPrompt</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui>