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>
</property>
<property name="currentIndex">
<number>3</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
+14 -1
View File
@@ -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<PlayerInterface>
}
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 closeMessageBoxes();
void hide();
void soundEvent_blindsWereSet(int);
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)
{
myW->getMySoundEventHandler()->blindsWereSet(sbSet);
myW->soundEvent_blindsWereSet(sbSet);
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 "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;
}
+3 -5
View File
@@ -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;
};