add sound-volume option

This commit is contained in:
doitux
2007-06-13 09:27:28 +00:00
parent 32a0d99a54
commit f225ef8956
15 changed files with 1363 additions and 1174 deletions
+3 -3
View File
@@ -631,7 +631,7 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
//Sound
mySDLPlayer = new SDLPlayer;
mySDLPlayer = new SDLPlayer(myConfig);
}
@@ -1007,7 +1007,7 @@ void mainWindowImpl::refreshPlayerAvatar() {
if(currentHand->getPlayerArray()[i]->getMyActiveStatus()) {
if(!i) {
if(currentHand->getPlayerArray()[0]->getMyAvatar() == "") {
if(currentHand->getPlayerArray()[0]->getMyAvatar() == "" || !QFile::QFile(QString::fromUtf8(currentHand->getPlayerArray()[0]->getMyAvatar().c_str())).exists()) {
playerAvatarLabelArray[0]->setPixmap(QPixmap(":/guiv2/resources/guiv2/genereticAvatar.png"));
}
else {
@@ -1015,7 +1015,7 @@ void mainWindowImpl::refreshPlayerAvatar() {
}
}
else {
if(currentHand->getPlayerArray()[i]->getMyAvatar() == "") {
if(currentHand->getPlayerArray()[i]->getMyAvatar() == "" || !QFile::QFile(QString::fromUtf8(currentHand->getPlayerArray()[i]->getMyAvatar().c_str())).exists()) {
playerAvatarLabelArray[i]->setPixmap(QPixmap(":/guiv2/resources/guiv2/genereticAvatar.png"));
}
else {
+374 -285
View File
@@ -5,10 +5,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>593</width>
<height>553</height>
<width>600</width>
<height>533</height>
</rect>
</property>
<property name="maximumSize" >
<size>
<width>600</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle" >
<string>Settings</string>
</property>
@@ -36,6 +42,47 @@
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QListWidget" name="listWidget" >
<property name="minimumSize" >
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text" >
<string>Interface</string>
</property>
</item>
<item>
<property name="text" >
<string>Local Game Settings</string>
</property>
</item>
<item>
<property name="text" >
<string>Network Game Settings</string>
</property>
</item>
<item>
<property name="text" >
<string>Player Nicks</string>
</property>
</item>
<item>
<property name="text" >
<string>Log Messages</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1" >
<widget class="QStackedWidget" name="stackedWidget" >
<property name="currentIndex" >
@@ -49,6 +96,94 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="9" column="0" >
<widget class="QGroupBox" name="groupBox_4" >
<property name="title" >
<string/>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" >
<widget class="QCheckBox" name="checkBox_playSoundEffects" >
<property name="text" >
<string>Play sound effects</string>
</property>
</widget>
</item>
<item row="0" column="2" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label_25" >
<property name="text" >
<string>Sound Volume:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_soundVolume" >
<property name="minimumSize" >
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="text" >
<string>10</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="horizontalSlider_soundVolume" >
<property name="minimum" >
<number>1</number>
</property>
<property name="maximum" >
<number>10</number>
</property>
<property name="value" >
<number>8</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="7" column="0" >
<widget class="QCheckBox" name="checkBox_showFlipCardsAnimation" >
<property name="text" >
<string>Show flip-card animation</string>
</property>
</widget>
</item>
<item row="10" column="0" >
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
@@ -143,12 +278,18 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item row="7" column="0" >
<widget class="QCheckBox" name="checkBox_showFlipCardsAnimation" >
<property name="text" >
<string>Show flip-card animation</string>
<item row="11" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
</widget>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="8" column="0" >
<widget class="QCheckBox" name="checkBox_showBlindButtons" >
@@ -212,26 +353,6 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="11" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="9" column="0" >
<widget class="QCheckBox" name="checkBox_playSoundEffects" >
<property name="text" >
<string>Play sound effects</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2" >
@@ -679,37 +800,203 @@ p, li { white-space: pre-wrap; }
<property name="spacing" >
<number>6</number>
</property>
<item row="5" column="0" >
<spacer>
<item row="1" column="0" >
<widget class="Line" name="line_4" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>451</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="label_38" >
<property name="text" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Nimbus Sans L'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-style:italic;">Note: Best avatar quality with image ratio like &lt;/span>&lt;span style=" font-weight:600; font-style:italic;">width=50, height=50.&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label_7" >
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Player Nicks</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>151</width>
<height>116</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>3</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="MyHPAvatarButton" name="pushButton_HumanPlayerAvatar" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>13</hsizetype>
<vsizetype>13</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="iconSize" >
<size>
<width>50</width>
<height>50</height>
</size>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>3</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0" >
<widget class="QLineEdit" name="lineEdit_HumanPlayerName" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maxLength" >
<number>12</number>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label_8" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="text" >
<string>Human Player:</string>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>151</width>
<height>116</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="3" column="0" >
<widget class="QGroupBox" name="groupBox_3" >
<property name="minimumSize" >
<size>
<width>359</width>
<height>273</height>
</size>
</property>
<property name="title" >
<string>Computer Engine</string>
</property>
@@ -718,7 +1005,7 @@ p, li { white-space: pre-wrap; }
<number>9</number>
</property>
<property name="spacing" >
<number>15</number>
<number>5</number>
</property>
<item row="1" column="2" >
<layout class="QGridLayout" >
@@ -1557,200 +1844,28 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item row="2" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>151</width>
<height>116</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>3</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="MyHPAvatarButton" name="pushButton_HumanPlayerAvatar" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>13</hsizetype>
<vsizetype>13</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="iconSize" >
<size>
<width>50</width>
<height>50</height>
</size>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>3</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0" >
<widget class="QLineEdit" name="lineEdit_HumanPlayerName" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maxLength" >
<number>12</number>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label_8" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="text" >
<string>Human Player:</string>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>151</width>
<height>116</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label_7" >
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<item row="4" column="0" >
<widget class="QLabel" name="label_38" >
<property name="text" >
<string>Player Nicks</string>
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Nimbus Sans L'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-style:italic;">Note: Best avatar quality with image ratio like &lt;/span>&lt;span style=" font-weight:600; font-style:italic;">width=50, height=50.&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="Line" name="line_4" >
<item row="5" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
<enum>Qt::Vertical</enum>
</property>
</widget>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
@@ -1965,47 +2080,6 @@ p, li { white-space: pre-wrap; }
</widget>
</widget>
</item>
<item row="0" column="0" >
<widget class="QListWidget" name="listWidget" >
<property name="minimumSize" >
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text" >
<string>Interface</string>
</property>
</item>
<item>
<property name="text" >
<string>Local Game Settings</string>
</property>
</item>
<item>
<property name="text" >
<string>Network Game Settings</string>
</property>
</item>
<item>
<property name="text" >
<string>Player Nicks</string>
</property>
</item>
<item>
<property name="text" >
<string>Log Messages</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<customwidgets>
@@ -2029,7 +2103,6 @@ p, li { white-space: pre-wrap; }
<tabstop>checkBox_showFadeOutCardsAnimation</tabstop>
<tabstop>checkBox_showFlipCardsAnimation</tabstop>
<tabstop>checkBox_showBlindButtons</tabstop>
<tabstop>checkBox_playSoundEffects</tabstop>
<tabstop>radioButton_flipsideTux</tabstop>
<tabstop>radioButton_flipsideOwn</tabstop>
<tabstop>lineEdit_OwnFlipsideFilename</tabstop>
@@ -2084,8 +2157,8 @@ p, li { white-space: pre-wrap; }
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>331</x>
<y>522</y>
<x>340</x>
<y>576</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
@@ -2141,5 +2214,21 @@ p, li { white-space: pre-wrap; }
</hint>
</hints>
</connection>
<connection>
<sender>horizontalSlider_soundVolume</sender>
<signal>valueChanged(int)</signal>
<receiver>label_soundVolume</receiver>
<slot>setNum(int)</slot>
<hints>
<hint type="sourcelabel" >
<x>546</x>
<y>264</y>
</hint>
<hint type="destinationlabel" >
<x>501</x>
<y>260</y>
</hint>
</hints>
</connection>
</connections>
</ui>
@@ -130,6 +130,7 @@ void settingsDialogImpl::exec() {
checkBox_showFlipCardsAnimation->setChecked(myConfig->readConfigInt("ShowFlipCardsAnimation"));
checkBox_showBlindButtons->setChecked(myConfig->readConfigInt("ShowBlindButtons"));
checkBox_playSoundEffects->setChecked(myConfig->readConfigInt("PlaySoundEffects"));
horizontalSlider_soundVolume->setValue(myConfig->readConfigInt("SoundVolume"));
radioButton_flipsideTux->setChecked(myConfig->readConfigInt("FlipsideTux"));
radioButton_flipsideOwn->setChecked(myConfig->readConfigInt("FlipsideOwn"));
if(radioButton_flipsideOwn->isChecked()) {
@@ -210,6 +211,7 @@ void settingsDialogImpl::isAccepted() {
myConfig->writeConfigInt("ShowFlipCardsAnimation", checkBox_showFlipCardsAnimation->isChecked());
myConfig->writeConfigInt("ShowBlindButtons", checkBox_showBlindButtons->isChecked());
myConfig->writeConfigInt("PlaySoundEffects", checkBox_playSoundEffects->isChecked());
myConfig->writeConfigInt("SoundVolume", horizontalSlider_soundVolume->value());
myConfig->writeConfigInt("FlipsideTux", radioButton_flipsideTux->isChecked());
myConfig->writeConfigInt("FlipsideOwn", radioButton_flipsideOwn->isChecked());
+7 -3
View File
@@ -15,8 +15,8 @@
using namespace std;
SDLPlayer::SDLPlayer()
: soundData(NULL), currentChannel(0) , audioEnabled(0)
SDLPlayer::SDLPlayer(ConfigFile *c)
: soundData(NULL), currentChannel(0) , audioEnabled(0), myConfig(c)
{
initAudio();
}
@@ -83,7 +83,11 @@ void SDLPlayer::playSound(string audioString, int playerID) {
sound = Mix_QuickLoad_WAV(soundData);
// set channel 2 to be behind and right, and 100 units away
// set channel 0 to settings volume
Mix_Volume(0,myConfig->readConfigInt("SoundVolume")*10);
// set 3d effect
if(!Mix_SetPosition(0, position, distance)) {
printf("Mix_SetPosition: %s\n", Mix_GetError());
// no position effect, is it ok?
+4 -1
View File
@@ -23,6 +23,7 @@
#endif
#include <string>
#include "configfile.h"
/**
@author FThauer FHammer <webmaster@pokerth.net>
@@ -31,7 +32,7 @@ class SDLPlayer : public QObject{
Q_OBJECT
public:
SDLPlayer();
SDLPlayer(ConfigFile*);
~SDLPlayer();
@@ -52,6 +53,8 @@ private:
bool audioEnabled;
ConfigFile *myConfig;
};
#endif