Fixed: Choice of sound driver

--HG--
branch : develop
This commit is contained in:
kervala 2016-10-30 15:35:11 +01:00
parent 1c872d9ef9
commit 8f6aa83a7b
2 changed files with 177 additions and 139 deletions

View file

@ -25,11 +25,16 @@ CSoundSettingsWidget::CSoundSettingsWidget( QWidget *parent ) :
setupUi( this );
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( soundCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) );
connect( eaxCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) );
connect( softwareCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) );
connect( fmodCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) );
}
CSoundSettingsWidget::~CSoundSettingsWidget()
@ -64,8 +69,38 @@ void CSoundSettingsWidget::load()
updateTracksLabel();
if( s.config.getString( "DriverSound" ).compare( "FMod" ) == 0 )
fmodCheckBox->setChecked( true );
std::string soundDriver = NLMISC::toLower(s.config.getString("DriverSound"));
#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()
@ -83,8 +118,18 @@ void CSoundSettingsWidget::save()
s.config.setInt( "MaxTrack", tracksSlider->value() * 4 );
if( fmodCheckBox->isChecked() )
s.config.setString( "DriverSound", std::string( "FMod" ) );
if (openalRadioButton->isChecked())
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()

View file

@ -6,147 +6,140 @@
<rect>
<x>0</x>
<y>0</y>
<width>391</width>
<height>429</height>
<width>294</width>
<height>317</height>
</rect>
</property>
<property name="windowTitle">
<string>Sound</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="soundCheckBox">
<property name="text">
<string>Enable sound</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="eaxCheckBox">
<property name="text">
<string>Enable EAX</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="fmodCheckBox">
<property name="text">
<string>Enable FMod</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="softwareCheckBox">
<property name="text">
<string>Software sound buffer (may increase FPS)</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<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>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>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="driverGroupBox">
<property name="title">
<string>Driver</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="autoRadioButton">
<property name="text">
<string>Auto</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="openalRadioButton">
<property name="text">
<string>OpenAL</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="fmodRadioButton">
<property name="text">
<string>FMod</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="xaudio2RadioButton">
<property name="text">
<string>XAudio2</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="directsoundRadioButton">
<property name="text">
<string>DirectSound</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item>
<widget class="QGroupBox" name="parametersGroupBox">
<property name="title">
<string>Parameters</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>180</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>223</height>
</size>
</property>
</spacer>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="soundCheckBox">
<property name="text">
<string>Enable sound</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="eaxCheckBox">
<property name="text">
<string>Enable EAX</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="softwareCheckBox">
<property name="text">
<string>Software sound buffer (may increase FPS)</string>
</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>
</layout>
</widget>