remove circular dependencies between soundevents and gametableimpl

This commit is contained in:
doitux
2012-01-01 19:55:22 +00:00
parent 6a3ffc1f29
commit cbb72bc06a
6 changed files with 28 additions and 14 deletions
+1 -1
View File
@@ -24,7 +24,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>3</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
+14 -1
View File
@@ -77,7 +77,7 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent)
//Sound //Sound
mySDLPlayer = new SDLPlayer(myConfig); mySDLPlayer = new SDLPlayer(myConfig);
mySoundEventHandler = new SoundEvents(myConfig, this); mySoundEventHandler = new SoundEvents(myConfig);
// Init game table style // Init game table style
myGameTableStyle = new GameTableStyleReader(myConfig, this); myGameTableStyle = new GameTableStyleReader(myConfig, this);
@@ -2875,6 +2875,9 @@ void gameTableImpl::breakButtonClicked()
pushButton_break->setText(tr("Stop")); pushButton_break->setText(tr("Stop"));
if(currentGameOver) { if(currentGameOver) {
//let the SoundEventHandler know that there is a new game
mySoundEventHandler->newGameStarts();
currentGameOver = FALSE; currentGameOver = FALSE;
myStartWindow->callNewGameDialog(); myStartWindow->callNewGameDialog();
//Bei Cancel nichts machen!!! //Bei Cancel nichts machen!!!
@@ -3173,6 +3176,9 @@ void gameTableImpl::localGameModification()
restoreGameTableGeometry(); restoreGameTableGeometry();
if(myGameTableStyle->getState() != GT_STYLE_OK) myGameTableStyle->showErrorMessage(); if(myGameTableStyle->getState() != GT_STYLE_OK) myGameTableStyle->showErrorMessage();
//let the SoundEventHandler know that there is a new game
mySoundEventHandler->newGameStarts();
} }
void gameTableImpl::networkGameModification() void gameTableImpl::networkGameModification()
@@ -3222,6 +3228,8 @@ void gameTableImpl::networkGameModification()
blinkingStartButtonAnimationTimer->stop(); blinkingStartButtonAnimationTimer->stop();
myGameTableStyle->setBreakButtonStyle(pushButton_break,0); myGameTableStyle->setBreakButtonStyle(pushButton_break,0);
//let the SoundEventHandler know that there is a new game
mySoundEventHandler->newGameStarts();
} }
void gameTableImpl::mouseOverFlipCards(bool front) void gameTableImpl::mouseOverFlipCards(bool front)
@@ -3842,3 +3850,8 @@ SeatState gameTableImpl::getCurrentSeatState(boost::shared_ptr<PlayerInterface>
} }
return SEAT_UNDEFINED; return SEAT_UNDEFINED;
} }
void gameTableImpl::soundEvent_blindsWereSet(int sbSet)
{
mySoundEventHandler->blindsWereSet(sbSet);
}
+1 -1
View File
@@ -336,8 +336,8 @@ public slots:
void sendShowMyCardsSignal(); void sendShowMyCardsSignal();
void closeMessageBoxes(); void closeMessageBoxes();
void hide(); void hide();
void soundEvent_blindsWereSet(int);
private: private:
+1 -1
View File
@@ -248,7 +248,7 @@ void GuiWrapper::logNewGameHandMsg(int gameID, int handID)
} }
void GuiWrapper::logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName) 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())); myGuiLog->signalLogNewBlindsSetsMsg(sbSet, bbSet, QString::fromUtf8(sbName.c_str()), QString::fromUtf8(bbName.c_str()));
} }
+8 -5
View File
@@ -1,11 +1,10 @@
#include "sdlplayer.h" #include "sdlplayer.h"
#include "configfile.h" #include "configfile.h"
#include "gametableimpl.h"
#include "session.h" #include "session.h"
#include "game.h" #include "game.h"
#include "soundevents.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); mySDLPlayer = new SDLPlayer(myConfig);
} }
@@ -17,12 +16,11 @@ SoundEvents::~SoundEvents()
void SoundEvents::blindsWereSet(int sB) void SoundEvents::blindsWereSet(int sB)
{ {
int currentGameId = myW->getSession()->getCurrentGame()->getMyGameID(); if(newGameNow)
if(currentGameId != lastGameId)
{ {
lastSBLevel = 0; lastSBLevel = 0;
lastSBValue = sB; lastSBValue = sB;
lastGameId = currentGameId; newGameNow = false;
} }
if(sB > lastSBValue) { if(sB > lastSBValue) {
@@ -44,3 +42,8 @@ void SoundEvents::blindsWereSet(int sB)
} }
} }
} }
void SoundEvents::newGameStarts()
{
newGameNow = true;
}
+3 -5
View File
@@ -3,24 +3,22 @@
class SDLPlayer; class SDLPlayer;
class ConfigFile; class ConfigFile;
class gameTableImpl;
class SoundEvents class SoundEvents
{ {
public: public:
SoundEvents(ConfigFile*, gameTableImpl*); SoundEvents(ConfigFile*);
~SoundEvents(); ~SoundEvents();
void blindsWereSet(int sB); void blindsWereSet(int sB);
void newGameStarts();
private: private:
SDLPlayer *mySDLPlayer; SDLPlayer *mySDLPlayer;
ConfigFile *myConfig; ConfigFile *myConfig;
gameTableImpl *myW;
unsigned int lastSBValue; unsigned int lastSBValue;
unsigned int lastSBLevel; unsigned int lastSBLevel;
unsigned int lastGameId; bool newGameNow;
}; };