From cbb72bc06afa206761a3800f43de8323340b12cb Mon Sep 17 00:00:00 2001 From: doitux Date: Sun, 1 Jan 2012 19:55:22 +0000 Subject: [PATCH] remove circular dependencies between soundevents and gametableimpl --- src/gui/qt/aboutpokerth.ui | 2 +- src/gui/qt/gametable/gametableimpl.cpp | 15 ++++++++++++++- src/gui/qt/gametable/gametableimpl.h | 2 +- src/gui/qt/guiwrapper.cpp | 2 +- src/gui/qt/sound/soundevents.cpp | 13 ++++++++----- src/gui/qt/sound/soundevents.h | 8 +++----- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/gui/qt/aboutpokerth.ui b/src/gui/qt/aboutpokerth.ui index 9079b05e..b5ced9bd 100755 --- a/src/gui/qt/aboutpokerth.ui +++ b/src/gui/qt/aboutpokerth.ui @@ -24,7 +24,7 @@ true - 3 + 0 diff --git a/src/gui/qt/gametable/gametableimpl.cpp b/src/gui/qt/gametable/gametableimpl.cpp index 2d77538d..7453998d 100755 --- a/src/gui/qt/gametable/gametableimpl.cpp +++ b/src/gui/qt/gametable/gametableimpl.cpp @@ -77,7 +77,7 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) //Sound mySDLPlayer = new SDLPlayer(myConfig); - mySoundEventHandler = new SoundEvents(myConfig, this); + mySoundEventHandler = new SoundEvents(myConfig); // Init game table style myGameTableStyle = new GameTableStyleReader(myConfig, this); @@ -2875,6 +2875,9 @@ void gameTableImpl::breakButtonClicked() pushButton_break->setText(tr("Stop")); if(currentGameOver) { + //let the SoundEventHandler know that there is a new game + mySoundEventHandler->newGameStarts(); + currentGameOver = FALSE; myStartWindow->callNewGameDialog(); //Bei Cancel nichts machen!!! @@ -3173,6 +3176,9 @@ void gameTableImpl::localGameModification() restoreGameTableGeometry(); if(myGameTableStyle->getState() != GT_STYLE_OK) myGameTableStyle->showErrorMessage(); + + //let the SoundEventHandler know that there is a new game + mySoundEventHandler->newGameStarts(); } void gameTableImpl::networkGameModification() @@ -3222,6 +3228,8 @@ void gameTableImpl::networkGameModification() blinkingStartButtonAnimationTimer->stop(); myGameTableStyle->setBreakButtonStyle(pushButton_break,0); + //let the SoundEventHandler know that there is a new game + mySoundEventHandler->newGameStarts(); } void gameTableImpl::mouseOverFlipCards(bool front) @@ -3842,3 +3850,8 @@ SeatState gameTableImpl::getCurrentSeatState(boost::shared_ptr } return SEAT_UNDEFINED; } + +void gameTableImpl::soundEvent_blindsWereSet(int sbSet) +{ + mySoundEventHandler->blindsWereSet(sbSet); +} diff --git a/src/gui/qt/gametable/gametableimpl.h b/src/gui/qt/gametable/gametableimpl.h index 988c0538..746dedf8 100755 --- a/src/gui/qt/gametable/gametableimpl.h +++ b/src/gui/qt/gametable/gametableimpl.h @@ -336,8 +336,8 @@ public slots: void sendShowMyCardsSignal(); void closeMessageBoxes(); - void hide(); + void soundEvent_blindsWereSet(int); private: diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index 98bd5c0c..ec29bd7b 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -248,7 +248,7 @@ void GuiWrapper::logNewGameHandMsg(int gameID, int handID) } void GuiWrapper::logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName) { - myW->getMySoundEventHandler()->blindsWereSet(sbSet); + myW->soundEvent_blindsWereSet(sbSet); myGuiLog->signalLogNewBlindsSetsMsg(sbSet, bbSet, QString::fromUtf8(sbName.c_str()), QString::fromUtf8(bbName.c_str())); } diff --git a/src/gui/qt/sound/soundevents.cpp b/src/gui/qt/sound/soundevents.cpp index e71983f6..dc825272 100644 --- a/src/gui/qt/sound/soundevents.cpp +++ b/src/gui/qt/sound/soundevents.cpp @@ -1,11 +1,10 @@ #include "sdlplayer.h" #include "configfile.h" -#include "gametableimpl.h" #include "session.h" #include "game.h" #include "soundevents.h" -SoundEvents::SoundEvents(ConfigFile *c, gameTableImpl *w): myConfig(c), myW(w), lastSBValue(0), lastSBLevel(0), lastGameId(0) +SoundEvents::SoundEvents(ConfigFile *c): myConfig(c), lastSBValue(0), lastSBLevel(0), newGameNow(false) { mySDLPlayer = new SDLPlayer(myConfig); } @@ -17,12 +16,11 @@ SoundEvents::~SoundEvents() void SoundEvents::blindsWereSet(int sB) { - int currentGameId = myW->getSession()->getCurrentGame()->getMyGameID(); - if(currentGameId != lastGameId) + if(newGameNow) { lastSBLevel = 0; lastSBValue = sB; - lastGameId = currentGameId; + newGameNow = false; } if(sB > lastSBValue) { @@ -44,3 +42,8 @@ void SoundEvents::blindsWereSet(int sB) } } } + +void SoundEvents::newGameStarts() +{ + newGameNow = true; +} diff --git a/src/gui/qt/sound/soundevents.h b/src/gui/qt/sound/soundevents.h index 2f352a68..066776c9 100644 --- a/src/gui/qt/sound/soundevents.h +++ b/src/gui/qt/sound/soundevents.h @@ -3,24 +3,22 @@ class SDLPlayer; class ConfigFile; -class gameTableImpl; class SoundEvents { public: - SoundEvents(ConfigFile*, gameTableImpl*); + SoundEvents(ConfigFile*); ~SoundEvents(); void blindsWereSet(int sB); - + void newGameStarts(); private: SDLPlayer *mySDLPlayer; ConfigFile *myConfig; - gameTableImpl *myW; unsigned int lastSBValue; unsigned int lastSBLevel; - unsigned int lastGameId; + bool newGameNow; };