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("OpenAL"));
#ifdef Q_OS_WIN32
else if (fmodRadioButton->isChecked())
s.config.setString("DriverSound", std::string("FMod")); 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,18 +6,64 @@
<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">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QGroupBox" name="driverGroupBox">
<property name="title">
<string>Driver</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <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>
<widget class="QGroupBox" name="parametersGroupBox">
<property name="title">
<string>Parameters</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QCheckBox" name="soundCheckBox"> <widget class="QCheckBox" name="soundCheckBox">
<property name="text"> <property name="text">
@ -32,13 +78,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="fmodCheckBox">
<property name="text">
<string>Enable FMod</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="softwareCheckBox"> <widget class="QCheckBox" name="softwareCheckBox">
<property name="text"> <property name="text">
@ -47,48 +86,14 @@
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer"> <widget class="QLabel" name="soundTracksLabel">
<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"> <property name="text">
<string>Sound tracks</string> <string>Sound tracks</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</item>
<item> <item>
<spacer name="verticalSpacer_2"> <layout class="QHBoxLayout" name="soundTracksHorizontalLayout">
<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> <item>
<widget class="QSlider" name="tracksSlider"> <widget class="QSlider" name="tracksSlider">
<property name="minimum"> <property name="minimum">
@ -120,36 +125,24 @@
</item> </item>
</layout> </layout>
</item> </item>
</layout> <item>
</item> <spacer name="verticalSpacer">
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</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"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>20</width>
<height>223</height> <height>40</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
</widget> </widget>
</item>
</layout>
</widget>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>