When navigating in the history, display the current turn in the status bar

This commit is contained in:
Olivier Teulière 2008-11-30 20:51:05 +00:00
parent fb4ea0e559
commit a79b71f028
3 changed files with 32 additions and 1 deletions

View file

@ -60,6 +60,24 @@ void Navigation::addAndExecute(Command *iCmd)
} }
unsigned int Navigation::getCurrTurn() const
{
unsigned int currTurn = m_currTurn;
if (isLastTurn() && m_turnCommands.back()->isEmpty())
--currTurn;
return currTurn;
}
unsigned int Navigation::getNbTurns() const
{
unsigned int count = m_turnCommands.size();
if (m_turnCommands.back()->isEmpty())
--count;
return count;
}
bool Navigation::isFirstTurn() const bool Navigation::isFirstTurn() const
{ {
return m_currTurn == 1 || return m_currTurn == 1 ||

View file

@ -38,7 +38,8 @@ class Navigation
void newTurn(); void newTurn();
void addAndExecute(Command *iCmd); void addAndExecute(Command *iCmd);
unsigned int getCurrTurn() const { return m_currTurn; } unsigned int getCurrTurn() const;
unsigned int getNbTurns() const;
bool isFirstTurn() const; bool isFirstTurn() const;
bool isLastTurn() const; bool isLastTurn() const;

View file

@ -789,6 +789,9 @@ void MainWindow::onHistoryFirstTurn()
m_game->accessNavigation().firstTurn(); m_game->accessNavigation().firstTurn();
emit gameUpdated(); emit gameUpdated();
unsigned int currTurn = m_game->getNavigation().getCurrTurn();
unsigned int nbTurns = m_game->getNavigation().getNbTurns();
displayInfoMsg(_q("Turn %1/%2").arg(currTurn).arg(nbTurns));
} }
@ -799,6 +802,9 @@ void MainWindow::onHistoryPrevTurn()
m_game->accessNavigation().prevTurn(); m_game->accessNavigation().prevTurn();
emit gameUpdated(); emit gameUpdated();
unsigned int currTurn = m_game->getNavigation().getCurrTurn();
unsigned int nbTurns = m_game->getNavigation().getNbTurns();
displayInfoMsg(_q("Turn %1/%2").arg(currTurn).arg(nbTurns));
} }
@ -809,6 +815,9 @@ void MainWindow::onHistoryNextTurn()
m_game->accessNavigation().nextTurn(); m_game->accessNavigation().nextTurn();
emit gameUpdated(); emit gameUpdated();
unsigned int currTurn = m_game->getNavigation().getCurrTurn();
unsigned int nbTurns = m_game->getNavigation().getNbTurns();
displayInfoMsg(_q("Turn %1/%2").arg(currTurn).arg(nbTurns));
} }
@ -819,6 +828,9 @@ void MainWindow::onHistoryLastTurn()
m_game->accessNavigation().lastTurn(); m_game->accessNavigation().lastTurn();
emit gameUpdated(); emit gameUpdated();
unsigned int currTurn = m_game->getNavigation().getCurrTurn();
unsigned int nbTurns = m_game->getNavigation().getNbTurns();
displayInfoMsg(_q("Turn %1/%2").arg(currTurn).arg(nbTurns));
} }