From 5c63a12104e00a515b1b60c0e2f505cb8b2c346c Mon Sep 17 00:00:00 2001 From: lotodore Date: Sat, 16 Jun 2007 09:48:23 +0000 Subject: [PATCH] All sounds are now only played if sound output is on (even the ping in network game). Audio is only initialized if it is enabled. Fixed double sounds in network games. Simplified fading out cards on fold. --- src/gui/generic/serverguiwrapper.cpp | 2 -- src/gui/generic/serverguiwrapper.h | 2 -- src/gui/guiinterface.h | 2 -- src/gui/qt/guiwrapper.cpp | 2 -- src/gui/qt/guiwrapper.h | 2 -- src/gui/qt/mainwindow/mainwindowimpl.cpp | 36 +++++++++--------------- src/gui/qt/mainwindow/mainwindowimpl.h | 4 --- src/gui/qt/sound/sdlplayer.cpp | 24 ++++++++-------- src/net/common/clientstate.cpp | 4 --- 9 files changed, 26 insertions(+), 52 deletions(-) diff --git a/src/gui/generic/serverguiwrapper.cpp b/src/gui/generic/serverguiwrapper.cpp index 0e01477a..8dbe6ca0 100644 --- a/src/gui/generic/serverguiwrapper.cpp +++ b/src/gui/generic/serverguiwrapper.cpp @@ -102,8 +102,6 @@ void ServerGuiWrapper::logDealBoardCardsMsg(int roundID, int card1, int card2, i void ServerGuiWrapper::logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt, std::string showHas) {} void ServerGuiWrapper::logPlayerWinGame(std::string playerName, int gameID) {} -void ServerGuiWrapper::fadeOutHumanPlayerCards() {} - void ServerGuiWrapper::SignalNetClientConnect(int actionID) { if (myClientcb) myClientcb->SignalNetClientConnect(actionID); } void ServerGuiWrapper::SignalNetClientGameInfo(int actionID) { if (myClientcb) myClientcb->SignalNetClientGameInfo(actionID); } void ServerGuiWrapper::SignalNetClientError(int errorID, int osErrorID) { if (myClientcb) myClientcb->SignalNetClientError(errorID, osErrorID); } diff --git a/src/gui/generic/serverguiwrapper.h b/src/gui/generic/serverguiwrapper.h index 5453c078..ed24cf72 100644 --- a/src/gui/generic/serverguiwrapper.h +++ b/src/gui/generic/serverguiwrapper.h @@ -86,8 +86,6 @@ public: void logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows") ; void logPlayerWinGame(std::string playerName, int gameID); - void fadeOutHumanPlayerCards(); - void SignalNetClientConnect(int actionID); void SignalNetClientGameInfo(int actionID); void SignalNetClientError(int errorID, int osErrorID); diff --git a/src/gui/guiinterface.h b/src/gui/guiinterface.h index 8aa06e1b..8b9004ab 100644 --- a/src/gui/guiinterface.h +++ b/src/gui/guiinterface.h @@ -88,8 +88,6 @@ public: virtual void startTimeoutAnimation(int playerId, int timeoutSec) =0; virtual void stopTimeoutAnimation(int playerId) =0; - virtual void fadeOutHumanPlayerCards() =0; - //log.cpp virtual void logPlayerActionMsg(std::string playName, int action, int setValue) =0; virtual void logNewGameHandMsg(int gameID, int HandID) =0; diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index b2165712..56099c78 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -97,8 +97,6 @@ void GuiWrapper::disableMyButtons() { myW->signalDisableMyButtons(); } void GuiWrapper::startTimeoutAnimation(int playerId, int timeoutSec) { myW->signalStartTimeoutAnimation(playerId, timeoutSec); } void GuiWrapper::stopTimeoutAnimation(int playerId) { myW->signalStopTimeoutAnimation(playerId); } -void GuiWrapper::fadeOutHumanPlayerCards() { myW->signalFadeOutHumanPlayerCards(); } - void GuiWrapper::logPlayerActionMsg(string playerName, int action, int setValue) { myLog->signalLogPlayerActionMsg(QString::fromUtf8(playerName.c_str()), action, setValue); } void GuiWrapper::logNewGameHandMsg(int gameID, int handID) { myLog->signalLogNewGameHandMsg(gameID, handID); } void GuiWrapper::logPlayerWinsMsg(int playerID, int pot) { myLog->signalLogPlayerWinsMsg(playerID, pot); } diff --git a/src/gui/qt/guiwrapper.h b/src/gui/qt/guiwrapper.h index b2376841..4e46196a 100644 --- a/src/gui/qt/guiwrapper.h +++ b/src/gui/qt/guiwrapper.h @@ -96,8 +96,6 @@ public: void logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows"); void logPlayerWinGame(std::string playerName, int gameID); - void fadeOutHumanPlayerCards(); - void SignalNetClientConnect(int actionID); void SignalNetClientGameInfo(int actionID); void SignalNetClientError(int errorID, int osErrorID); diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index 1951fd16..ef040cf4 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -629,9 +629,6 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent) connect(this, SIGNAL(signalNetServerPlayerJoined(QString)), myStartNetworkGameDialog, SLOT(addConnectedPlayer(QString))); connect(this, SIGNAL(signalNetServerPlayerLeft(QString)), myStartNetworkGameDialog, SLOT(removePlayer(QString))); - connect(this, SIGNAL(signalFadeOutHumanPlayerCards()), this, SLOT( fadeOutHumanPlayerCards())); - - //Sound mySDLPlayer = new SDLPlayer(myConfig); @@ -841,8 +838,9 @@ void mainWindowImpl::callSettingsDialog() { } } } - //Audio Clean? - if (myConfig->readConfigInt("PlaySoundEffects") == 0) { mySDLPlayer->audioDone(); } + // Re-init audio. + mySDLPlayer->closeAudio(); + mySDLPlayer->initAudio(); } } @@ -1078,13 +1076,16 @@ void mainWindowImpl::refreshAction(int playerID, int playerAction) { actionLabelArray[playerID]->setPixmap(QPixmap(":/actions/resources/graphics/actions/action_"+actionArray[playerAction]+".png")); //play sounds if exist - if(myConfig->readConfigInt("PlaySoundEffects")) mySDLPlayer->playSound(actionArray[playerAction].toStdString(), playerID); + mySDLPlayer->playSound(actionArray[playerAction].toStdString(), playerID); } - if (playerAction == 1) { - // groupBoxArray[i]->setDisabled(TRUE); - - if(playerID != 0) { + if (playerAction == 1) { // FOLD + + if (playerID == 0) { + holeCardsArray[0][0]->startFadeOut(10); + holeCardsArray[0][1]->startFadeOut(10); + } + else { holeCardsArray[playerID][0]->setPixmap(onePix, FALSE); holeCardsArray[playerID][1]->setPixmap(onePix, FALSE); } @@ -1584,12 +1585,6 @@ void mainWindowImpl::myFold(){ currentHand->getPlayerArray()[0]->setMyAction(1); currentHand->getPlayerArray()[0]->setMyTurn(0); - if (!mySession->isNetworkClientRunning()) - { - holeCardsArray[0][0]->startFadeOut(10); - holeCardsArray[0][1]->startFadeOut(10); - } - //set that i was the last active player. need this for unhighlighting groupbox currentHand->setLastPlayersTurn(0); @@ -1809,7 +1804,8 @@ void mainWindowImpl::myActionDone() { // TODO: Should not call in networking game. disableMyButtons(); - nextPlayerAnimation(); + if (!mySession->isNetworkClientRunning()) + nextPlayerAnimation(); } void mainWindowImpl::nextPlayerAnimation() { @@ -2646,12 +2642,6 @@ void mainWindowImpl::networkGameModification() { } -void mainWindowImpl::fadeOutHumanPlayerCards() { - - holeCardsArray[0][0]->startFadeOut(10); - holeCardsArray[0][1]->startFadeOut(10); -} - void mainWindowImpl::closeEvent(QCloseEvent *event) { quitPokerTH(); } void mainWindowImpl::quitPokerTH() { diff --git a/src/gui/qt/mainwindow/mainwindowimpl.h b/src/gui/qt/mainwindow/mainwindowimpl.h index 19183cc8..c35170a1 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.h +++ b/src/gui/qt/mainwindow/mainwindowimpl.h @@ -129,8 +129,6 @@ signals: void signalNetServerPlayerJoined(QString playerName); void signalNetServerPlayerLeft(QString playerName); - void signalFadeOutHumanPlayerCards(); - public slots: void initGui(int speed); @@ -270,8 +268,6 @@ public slots: void localGameModification(); void networkGameModification(); - void fadeOutHumanPlayerCards(); - void quitPokerTH(); diff --git a/src/gui/qt/sound/sdlplayer.cpp b/src/gui/qt/sound/sdlplayer.cpp index 4043f4a8..f53f25eb 100644 --- a/src/gui/qt/sound/sdlplayer.cpp +++ b/src/gui/qt/sound/sdlplayer.cpp @@ -18,6 +18,7 @@ using namespace std; SDLPlayer::SDLPlayer(ConfigFile *c) : soundData(NULL), currentChannel(0) , audioEnabled(0), myConfig(c) { + SDL_Init(SDL_INIT_AUDIO); initAudio(); } @@ -25,21 +26,23 @@ SDLPlayer::SDLPlayer(ConfigFile *c) SDLPlayer::~SDLPlayer() { closeAudio(); + SDL_Quit(); } void SDLPlayer::initAudio() { - audio_rate = 44100; - audio_format = AUDIO_S16; /* 16-bit stereo */ - audio_channels = 2; - audio_buffers = 4096; - sound = NULL; + if (myConfig->readConfigInt("PlaySoundEffects")) + { + audio_rate = 44100; + audio_format = AUDIO_S16; /* 16-bit stereo */ + audio_channels = 2; + audio_buffers = 4096; + sound = NULL; - SDL_Init(SDL_INIT_AUDIO); - - if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) == 0) { - Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels); - audioEnabled = 1; + if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) == 0) { + Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels); + audioEnabled = 1; + } } } @@ -121,5 +124,4 @@ void SDLPlayer::closeAudio() { audioDone(); Mix_CloseAudio(); } - SDL_Quit(); } diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index fb254fe4..f88a6683 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -640,11 +640,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptrgetMyID() == 0) - { client.GetGui().disableMyButtons(); - if (tmpPlayer->getMyAction() == PLAYER_ACTION_FOLD) - client.GetGui().fadeOutHumanPlayerCards(); - } client.GetGui().refreshAction(tmpPlayer->getMyID(), tmpPlayer->getMyAction()); client.GetGui().refreshPot(); client.GetGui().refreshSet();