mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-12-27 09:58:08 +01:00
Reset the timer automatically when a new turn starts
This commit is contained in:
parent
c89e91010c
commit
e355acc4fb
2 changed files with 16 additions and 3 deletions
|
@ -81,7 +81,7 @@ MainWindow::MainWindow(QWidget *iParent)
|
|||
m_bagWindow(NULL), m_boardWindow(NULL),
|
||||
m_historyWindow(NULL), m_statsWindow(NULL), m_timerWindow(NULL),
|
||||
m_dicToolsWindow(NULL), m_dicNameLabel(NULL), m_timerModel(NULL),
|
||||
m_currentTurn(0)
|
||||
m_currentTurn(0), m_lastTurn(0)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
// Check that the string conversion routines are not buggy
|
||||
|
@ -116,6 +116,8 @@ MainWindow::MainWindow(QWidget *iParent)
|
|||
this, SLOT(beep()));
|
||||
QObject::connect(m_timerModel, SIGNAL(expired()),
|
||||
this, SLOT(beep()));
|
||||
QObject::connect(this, SIGNAL(newTurn(int)),
|
||||
m_timerModel, SLOT(resetTimer()));
|
||||
|
||||
QObject::connect(this, SIGNAL(gameChangedNonConst(PublicGame*)),
|
||||
this, SLOT(updateForGame(PublicGame*)));
|
||||
|
@ -262,12 +264,18 @@ void MainWindow::refresh()
|
|||
m_actionHistoryReplayTurn->setEnabled(!isLastTurn);
|
||||
if (m_game->isFinished())
|
||||
displayInfoMsg(_q("End of the game"));
|
||||
// Emit the turnChanged() sign if needed.
|
||||
// Emit the turnChanged() signal if needed
|
||||
if (currTurn != m_currentTurn)
|
||||
{
|
||||
m_currentTurn = currTurn;
|
||||
emit turnChanged(currTurn, isLastTurn);
|
||||
}
|
||||
// Emit the newTurn() signal if needed
|
||||
if (currTurn > m_lastTurn)
|
||||
{
|
||||
m_lastTurn = currTurn;
|
||||
emit newTurn(currTurn);
|
||||
}
|
||||
|
||||
// Update the auto-saved game
|
||||
try
|
||||
|
|
|
@ -62,6 +62,8 @@ signals:
|
|||
void gameChangedNonConst(PublicGame *iGame);
|
||||
void gameUpdated();
|
||||
void turnChanged(int iCurrTurn, bool isLastTurn);
|
||||
/// Like turnChanged(), but only emitted when a new turn is created
|
||||
void newTurn(int iCurrTurn);
|
||||
|
||||
public slots:
|
||||
/// Display an error message to the user
|
||||
|
@ -195,9 +197,12 @@ private:
|
|||
/// Model for the timer widgets
|
||||
TimerModel *m_timerModel;
|
||||
|
||||
/// Last known turn number. Used to emit turnChanged().
|
||||
/// Current turn number. Used to emit turnChanged().
|
||||
unsigned m_currentTurn;
|
||||
|
||||
/// Last known turn number. Used to emit newTurn().
|
||||
unsigned m_lastTurn;
|
||||
|
||||
/// Save window state
|
||||
void writeSettings() const;
|
||||
/// Restore window state
|
||||
|
|
Loading…
Reference in a new issue