Fixed: Choice of sound driver

This commit is contained in:
kervala 2016-10-30 15:35:11 +01:00
parent 0fa7db915e
commit 7023fc88ac
2 changed files with 177 additions and 139 deletions

View file

@ -25,11 +25,16 @@ CSoundSettingsWidget::CSoundSettingsWidget( QWidget *parent ) :
setupUi( this ); setupUi( this );
load(); load();
connect(autoRadioButton, SIGNAL(clicked(bool)), this, SLOT(onSomethingChanged()));
connect(openalRadioButton, SIGNAL(clicked(bool)), this, SLOT(onSomethingChanged()));
connect(fmodRadioButton, SIGNAL(clicked(bool)), this, SLOT(onSomethingChanged()));
connect(xaudio2RadioButton, SIGNAL(clicked(bool)), this, SLOT(onSomethingChanged()));
connect(directsoundRadioButton, SIGNAL(clicked(bool)), this, SLOT(onSomethingChanged()));
connect( tracksSlider, SIGNAL( valueChanged( int ) ), this, SLOT( onTracksSliderChange() ) ); connect( tracksSlider, SIGNAL( valueChanged( int ) ), this, SLOT( onTracksSliderChange() ) );
connect( soundCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) ); connect( soundCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) );
connect( eaxCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) ); connect( eaxCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) );
connect( softwareCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) ); connect( softwareCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) );
connect( fmodCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) );
} }
CSoundSettingsWidget::~CSoundSettingsWidget() CSoundSettingsWidget::~CSoundSettingsWidget()
@ -64,8 +69,38 @@ void CSoundSettingsWidget::load()
updateTracksLabel(); updateTracksLabel();
if( s.config.getString( "DriverSound" ).compare( "FMod" ) == 0 ) std::string soundDriver = NLMISC::toLower(s.config.getString("DriverSound"));
fmodCheckBox->setChecked( true );
#ifdef Q_OS_WIN32
fmodRadioButton->setEnabled(true);
xaudio2RadioButton->setEnabled(true);
directsoundRadioButton->setEnabled(true);
#else
fmodRadioButton->setEnabled(false);
xaudio2RadioButton->setEnabled(false);
directsoundRadioButton->setEnabled(false);
#endif
if (soundDriver.compare("openal") == 0)
{
openalRadioButton->setChecked(true);
}
else if (soundDriver.compare("fmod") == 0)
{
fmodRadioButton->setChecked(true);
}
else if (soundDriver.compare("xaudio2") == 0)
{
xaudio2RadioButton->setChecked(true);
}
else if (soundDriver.compare("directsound") == 0)
{
directsoundRadioButton->setChecked(true);
}
else
{
autoRadioButton->setChecked(true);
}
} }
void CSoundSettingsWidget::save() void CSoundSettingsWidget::save()
@ -83,8 +118,18 @@ void CSoundSettingsWidget::save()
s.config.setInt( "MaxTrack", tracksSlider->value() * 4 ); s.config.setInt( "MaxTrack", tracksSlider->value() * 4 );
if( fmodCheckBox->isChecked() ) if (openalRadioButton->isChecked())
s.config.setString( "DriverSound", std::string( "FMod" ) ); s.config.setString("DriverSound", std::string("OpenAL"));
#ifdef Q_OS_WIN32
else if (fmodRadioButton->isChecked())
s.config.setString("DriverSound", std::string("FMod"));
else if (xaudio2RadioButton->isChecked())
s.config.setString("DriverSound", std::string("XAudio2"));
else if (directsoundRadioButton->isChecked())
s.config.setString("DriverSound", std::string("DirectSound"));
#endif
else
s.config.setString("DriverSound", std::string("Auto"));
} }
void CSoundSettingsWidget::updateTracksLabel() void CSoundSettingsWidget::updateTracksLabel()

View file

@ -6,147 +6,140 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>391</width> <width>294</width>
<height>429</height> <height>317</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Sound</string> <string>Sound</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item row="0" column="0"> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <widget class="QGroupBox" name="driverGroupBox">
<item> <property name="title">
<layout class="QVBoxLayout" name="verticalLayout"> <string>Driver</string>
<item> </property>
<widget class="QCheckBox" name="soundCheckBox"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="text"> <item>
<string>Enable sound</string> <widget class="QRadioButton" name="autoRadioButton">
</property> <property name="text">
</widget> <string>Auto</string>
</item> </property>
<item> </widget>
<widget class="QCheckBox" name="eaxCheckBox"> </item>
<property name="text"> <item>
<string>Enable EAX</string> <widget class="QRadioButton" name="openalRadioButton">
</property> <property name="text">
</widget> <string>OpenAL</string>
</item> </property>
<item> </widget>
<widget class="QCheckBox" name="fmodCheckBox"> </item>
<property name="text"> <item>
<string>Enable FMod</string> <widget class="QRadioButton" name="fmodRadioButton">
</property> <property name="text">
</widget> <string>FMod</string>
</item> </property>
<item> </widget>
<widget class="QCheckBox" name="softwareCheckBox"> </item>
<property name="text"> <item>
<string>Software sound buffer (may increase FPS)</string> <widget class="QRadioButton" name="xaudio2RadioButton">
</property> <property name="text">
</widget> <string>XAudio2</string>
</item> </property>
<item> </widget>
<spacer name="verticalSpacer"> </item>
<property name="orientation"> <item>
<enum>Qt::Vertical</enum> <widget class="QRadioButton" name="directsoundRadioButton">
</property> <property name="text">
<property name="sizeType"> <string>DirectSound</string>
<enum>QSizePolicy::Maximum</enum> </property>
</property> </widget>
<property name="sizeHint" stdset="0"> </item>
<size> </layout>
<width>20</width> </widget>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Sound tracks</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>18</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSlider" name="tracksSlider">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>8</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>4</number>
</property>
<property name="value">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="tracksLabel">
<property name="text">
<string>8 tracks</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item> </item>
<item row="0" column="1"> <item>
<spacer name="horizontalSpacer"> <widget class="QGroupBox" name="parametersGroupBox">
<property name="orientation"> <property name="title">
<enum>Qt::Horizontal</enum> <string>Parameters</string>
</property> </property>
<property name="sizeHint" stdset="0"> <layout class="QVBoxLayout" name="verticalLayout_2">
<size> <item>
<width>180</width> <widget class="QCheckBox" name="soundCheckBox">
<height>20</height> <property name="text">
</size> <string>Enable sound</string>
</property> </property>
</spacer> </widget>
</item> </item>
<item row="1" column="0"> <item>
<spacer name="verticalSpacer_3"> <widget class="QCheckBox" name="eaxCheckBox">
<property name="orientation"> <property name="text">
<enum>Qt::Vertical</enum> <string>Enable EAX</string>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size> </item>
<width>20</width> <item>
<height>223</height> <widget class="QCheckBox" name="softwareCheckBox">
</size> <property name="text">
</property> <string>Software sound buffer (may increase FPS)</string>
</spacer> </property>
</widget>
</item>
<item>
<widget class="QLabel" name="soundTracksLabel">
<property name="text">
<string>Sound tracks</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="soundTracksHorizontalLayout">
<item>
<widget class="QSlider" name="tracksSlider">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>8</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>4</number>
</property>
<property name="value">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="tracksLabel">
<property name="text">
<string>8 tracks</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>
</layout>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>