void CGameReviewDialog::OnPrev() { if (m_nPlayRound == 0) return; // get the game record CGameRecord* pGameRecord = pDOC->GetGameRecord(m_nGameIndex); // undo the last trick CEasyBDoc* pDoc = pDOC; int numCardsPlayed = pDoc->GetNumCardsPlayedInRound(); // return if there's nothing to undo if ((m_nPlayRound == 0) && (numCardsPlayed == 0)) return; // decrement the play round one extra if at the end of play record // play round = # of rounds played so far // undo cards from the current trick, if it has cards if (numCardsPlayed > 0) { pDoc->UndoTrick(); m_nPlayRound--; m_nPlayIndex -= numCardsPlayed; } // see if we're at the start if (m_nPlayRound == 0) { // can't go back any further SetPlayRound(0); // hide dummy pDOC->ExposeDummy(FALSE); // pVIEW->PostMessage(WM_COMMAND, WMS_RESET_DISPLAY, 1L); pMAINFRAME->SetStatusMessage("Start of play record."); pDOC->UpdatePlayHistory(); return; } // if past the first round, clear the previous trick as well pDoc->UndoPreviousTrick(); m_nPlayRound--; m_nPlayIndex -= 4; if (m_nPlayIndex < 0) m_nPlayIndex = 0; // pDoc->ResetDisplay(); pVIEW->DisplayTricks(); // then re-display the trick OnNext(); }
void CGameReviewDialog::OnFirst() { // undo the last trick CEasyBDoc* pDoc = pDOC; int numCardsPlayed = pDoc->GetNumCardsPlayedInRound(); // return if there's nothing to undo if ((m_nPlayRound == 0) && (numCardsPlayed == 0)) return; // suppress flashing CWaitCursor wait; pDoc->SuppressPlayHistoryUpdate(TRUE); pMAINFRAME->SetStatusMessage(_T("Backing up to the beginning of play...")); // decrement the play round one extra if at the end of play record if (m_nPlayRound > m_numTricksAvailable) m_nPlayRound--; // undo cards from the current trick if (numCardsPlayed > 0) { pDoc->UndoTrick(); m_nPlayRound--; m_nPlayIndex -= numCardsPlayed; } // and all previous tricks while(m_nPlayRound > 0) { pDoc->UndoPreviousTrick(); m_nPlayRound--; m_nPlayIndex -= 4; } // and reset SetPlayRound(0); // hide dummy pDOC->ExposeDummy(FALSE); // and reset display pDoc->ResetDisplay(); pMAINFRAME->ClearStatusMessage(); pDoc->SuppressPlayHistoryUpdate(FALSE); pDOC->UpdatePlayHistory(); // done return; }