From 81b44a8050f578e3dd594e7bbee0866e339df88d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Teuli=C3=A8re?= Date: Sun, 30 Nov 2008 21:08:29 +0000 Subject: [PATCH] - When displaying an old turn, do not allow playing - Turns start at 0 instead of 1, to indicate that nothing was played on the first turn --- game/navigation.cpp | 4 ++-- qt/player_widget.cpp | 15 ++++++++++++--- qt/training_widget.cpp | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/game/navigation.cpp b/game/navigation.cpp index 8db2839..8648090 100644 --- a/game/navigation.cpp +++ b/game/navigation.cpp @@ -65,7 +65,7 @@ unsigned int Navigation::getCurrTurn() const unsigned int currTurn = m_currTurn; if (isLastTurn() && m_turnCommands.back()->isEmpty()) --currTurn; - return currTurn; + return currTurn - 1; } @@ -74,7 +74,7 @@ unsigned int Navigation::getNbTurns() const unsigned int count = m_turnCommands.size(); if (m_turnCommands.back()->isEmpty()) --count; - return count; + return count - 1; } diff --git a/qt/player_widget.cpp b/qt/player_widget.cpp index fb41a92..cd971f7 100644 --- a/qt/player_widget.cpp +++ b/qt/player_widget.cpp @@ -134,9 +134,18 @@ void PlayerWidget::refresh() lineEditCoords->clear(); lineEditChange->clear(); - // Do not allow messing with AI players or with players who already played - setEnabled(!m_game->hasPlayed(m_player) && - m_game->getPlayer(m_player).isHuman()); + if (!m_game->isLastTurn()) + { + // Do not allow entering a move when displaying an old turn + setEnabled(false); + } + else + { + // Do not allow messing with AI players or with players + // who already played + setEnabled(!m_game->hasPlayed(m_player) && + m_game->getPlayer(m_player).isHuman()); + } } diff --git a/qt/training_widget.cpp b/qt/training_widget.cpp index 7c567d2..ae6ec16 100644 --- a/qt/training_widget.cpp +++ b/qt/training_widget.cpp @@ -117,6 +117,8 @@ void TrainingWidget::refresh() pushButtonComplement->setEnabled(true); pushButtonSearch->setEnabled(m_model->rowCount() == 0 && lineEditRack->text() != ""); + // Do not allow entering a move when displaying an old turn + setEnabled(m_game->isLastTurn()); } }