mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-12-28 09:58:15 +01:00
Do not allow navigating before the first turn, and do not count an empty turn as a real one when navigating.
The navigation in the history is now more natural.
This commit is contained in:
parent
8e7c61e2d8
commit
fa225881c0
3 changed files with 37 additions and 8 deletions
|
@ -60,12 +60,32 @@ void Navigation::addAndExecute(Command *iCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Navigation::isFirstTurn() const
|
||||||
|
{
|
||||||
|
return m_currTurn == 1 ||
|
||||||
|
(m_currTurn == 2 && m_turnCommands[1]->isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Navigation::isLastTurn() const
|
||||||
|
{
|
||||||
|
return m_currTurn == m_turnCommands.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Navigation::prevTurn()
|
void Navigation::prevTurn()
|
||||||
{
|
{
|
||||||
if (m_currTurn > 0)
|
if (m_currTurn > 1)
|
||||||
{
|
{
|
||||||
--m_currTurn;
|
--m_currTurn;
|
||||||
m_turnCommands[m_currTurn]->undo();
|
m_turnCommands[m_currTurn]->undo();
|
||||||
|
// Special case: when the last turn is empty, automatically
|
||||||
|
// undo the previous turn as well
|
||||||
|
if (m_currTurn + 1 == m_turnCommands.size() &&
|
||||||
|
m_turnCommands[m_currTurn]->isEmpty())
|
||||||
|
{
|
||||||
|
prevTurn();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,13 +96,20 @@ void Navigation::nextTurn()
|
||||||
{
|
{
|
||||||
m_turnCommands[m_currTurn]->execute();
|
m_turnCommands[m_currTurn]->execute();
|
||||||
++m_currTurn;
|
++m_currTurn;
|
||||||
|
// Special case: when the last turn is empty, automatically
|
||||||
|
// execute it
|
||||||
|
if (m_currTurn + 1 == m_turnCommands.size() &&
|
||||||
|
m_turnCommands[m_currTurn]->isEmpty())
|
||||||
|
{
|
||||||
|
nextTurn();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Navigation::firstTurn()
|
void Navigation::firstTurn()
|
||||||
{
|
{
|
||||||
while (m_currTurn > 0)
|
while (m_currTurn > 1)
|
||||||
{
|
{
|
||||||
prevTurn();
|
prevTurn();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,8 @@ class Navigation
|
||||||
void addAndExecute(Command *iCmd);
|
void addAndExecute(Command *iCmd);
|
||||||
|
|
||||||
unsigned int getCurrTurn() const { return m_currTurn; }
|
unsigned int getCurrTurn() const { return m_currTurn; }
|
||||||
bool isFirstTurn() const { return m_currTurn == 0; }
|
bool isFirstTurn() const;
|
||||||
bool isLastTurn() const { return m_currTurn == m_turnCommands.size(); }
|
bool isLastTurn() const;
|
||||||
|
|
||||||
void firstTurn();
|
void firstTurn();
|
||||||
void prevTurn();
|
void prevTurn();
|
||||||
|
|
|
@ -136,10 +136,12 @@ void Training::recordPlayerMove(const Move &iMove, Player &ioPlayer)
|
||||||
|
|
||||||
void Training::start()
|
void Training::start()
|
||||||
{
|
{
|
||||||
if (getNPlayers() != 0)
|
firstPlayer();
|
||||||
return;
|
// Dummy new turn, because the navigation prevents undoing the first turn.
|
||||||
|
// Since in this mode the player can set the rack, we cannot do like in the
|
||||||
m_currPlayer = 0;
|
// duplicate and free game modes, where we change turn just before a move
|
||||||
|
// is played...
|
||||||
|
accessNavigation().newTurn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue