diff options
author | John Fultz <jfultz@wolfram.com> | 2019-01-14 02:46:35 -0600 |
---|---|---|
committer | John Fultz <jfultz@wolfram.com> | 2019-01-14 02:47:01 -0600 |
commit | 2c6b3b89da2a728ba6683d9f4455139372beb21b (patch) | |
tree | 17e01fc5b5e736ec42b9b5e406371f03b1da216b | |
parent | 3938bd82ac4ac35916c83b378776159952f744eb (diff) |
Fix #21, committing a phoney cannot be canceled.
When going back to edit history, typing a
phoney correctly brought up a dialog, but
indicating you wanted to cancel the phoney
play didn't stop the play from going down,
or a subsequent computer player from making
its play.
-rw-r--r-- | quacker/boarddisplay.cpp | 8 | ||||
-rw-r--r-- | quacker/graphicalboard.cpp | 14 | ||||
-rw-r--r-- | quacker/graphicalboard.h | 2 | ||||
-rw-r--r-- | quacker/movebox.cpp | 6 | ||||
-rw-r--r-- | quacker/quacker.cpp | 10 | ||||
-rw-r--r-- | quacker/quacker.h | 2 | ||||
-rw-r--r-- | quacker/view.cpp | 2 | ||||
-rw-r--r-- | quacker/view.h | 2 |
8 files changed, 27 insertions, 19 deletions
diff --git a/quacker/boarddisplay.cpp b/quacker/boarddisplay.cpp index fb6a3ba..78eacdd 100644 --- a/quacker/boarddisplay.cpp +++ b/quacker/boarddisplay.cpp @@ -107,18 +107,18 @@ void BoardWithQuickEntry::quickEditShiftReturnPressed() void BoardWithQuickEntry::plusFive() { m_localCandidateMove.setScoreAddition(m_localCandidateMove.scoreAddition() + 5); - emit setCandidateMove(m_localCandidateMove); + emit setCandidateMove(m_localCandidateMove, nullptr); } void BoardWithQuickEntry::performCommit() { - emit setCandidateMove(m_localCandidateMove); + emit setCandidateMove(m_localCandidateMove, nullptr); emit commit(); } void BoardWithQuickEntry::reset() { - emit setCandidateMove(Quackle::Move::createNonmove()); + emit setCandidateMove(Quackle::Move::createNonmove(), nullptr); } void BoardWithQuickEntry::provideHelp() @@ -203,7 +203,7 @@ void BoardWithQuickEntry::processCommand(const QString &command) } if (move.isAMove()) - emit setCandidateMove(move); + emit setCandidateMove(move, nullptr); } /////////// diff --git a/quacker/graphicalboard.cpp b/quacker/graphicalboard.cpp index 7bc3fa8..35864bf 100644 --- a/quacker/graphicalboard.cpp +++ b/quacker/graphicalboard.cpp @@ -745,7 +745,7 @@ void GraphicalBoardFrame::deleteHandler() void GraphicalBoardFrame::submitHandler() { - QTimer::singleShot(0, this, SLOT(setGlobalCandidate())); + QTimer::singleShot(0, this, SLOT(setGlobalCandidate(nullptr))); } void GraphicalBoardFrame::commitHandler() @@ -753,7 +753,7 @@ void GraphicalBoardFrame::commitHandler() QTimer::singleShot(0, this, SLOT(setAndCommitGlobalCandidate())); } -void GraphicalBoardFrame::setGlobalCandidate() +void GraphicalBoardFrame::setGlobalCandidate(bool *carryOn) { if (m_candidate.action == Quackle::Move::Place && m_candidate.wordTilesWithNoPlayThru().empty()) { @@ -763,18 +763,20 @@ void GraphicalBoardFrame::setGlobalCandidate() if (m_candidate.wordTilesWithNoPlayThru().length() == 1) { - emit setCandidateMove(flip(m_candidate)); + emit setCandidateMove(flip(m_candidate), carryOn); } else { - emit setCandidateMove(m_candidate); + emit setCandidateMove(m_candidate, carryOn); } } void GraphicalBoardFrame::setAndCommitGlobalCandidate() { - setGlobalCandidate(); - emit commit(); + bool carryOn = false; + setGlobalCandidate(&carryOn); + if (carryOn) + emit commit(); } void GraphicalBoardFrame::appendHandler(const QString &text, bool shiftPressed) diff --git a/quacker/graphicalboard.h b/quacker/graphicalboard.h index 98971d0..500628c 100644 --- a/quacker/graphicalboard.h +++ b/quacker/graphicalboard.h @@ -143,7 +143,7 @@ protected slots: void commitHandler(); void appendHandler(const QString &text, bool shiftPressed); - void setGlobalCandidate(); + void setGlobalCandidate(bool *carryOn); // returns false if the user canceled a badly formed move void setAndCommitGlobalCandidate(); virtual void tileClicked(const QSize &tileLocation, const QMouseEvent * /* event */); diff --git a/quacker/movebox.cpp b/quacker/movebox.cpp index 7b6ccd9..c7e5156 100644 --- a/quacker/movebox.cpp +++ b/quacker/movebox.cpp @@ -61,7 +61,7 @@ void MoveBox::moveActivated(QTreeWidgetItem *item) { if (item == 0) { - emit setCandidateMove(Quackle::Move::createNonmove()); + emit setCandidateMove(Quackle::Move::createNonmove(), nullptr); return; } @@ -73,7 +73,7 @@ void MoveBox::moveActivated(QTreeWidgetItem *item) { if (it.value() == item) { - emit setCandidateMove(it.key()); + emit setCandidateMove(it.key(), nullptr); break; } } @@ -130,7 +130,7 @@ void MoveBox::removeMove() { if (mapIt.value() == nextSelection) { - emit setCandidateMove(mapIt.key()); + emit setCandidateMove(mapIt.key(), nullptr); break; } } diff --git a/quacker/quacker.cpp b/quacker/quacker.cpp index 275003f..2734ac8 100644 --- a/quacker/quacker.cpp +++ b/quacker/quacker.cpp @@ -269,8 +269,10 @@ bool TopLevel::askToCarryOn(const QString &text) return QMessageBox::question(this, tr("Verify Play - Quackle"), dialogText(text), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes; } -void TopLevel::setCandidateMove(const Quackle::Move &move) +void TopLevel::setCandidateMove(const Quackle::Move &move, bool *carryOnPtr) { + if (carryOnPtr != nullptr) + *carryOnPtr = true; if (!m_game->hasPositions() || (move.action == Quackle::Move::Place && move.tiles().empty())) return; @@ -371,7 +373,11 @@ void TopLevel::setCandidateMove(const Quackle::Move &move) } if (!carryOn) + { + if (carryOnPtr != nullptr) + *carryOnPtr = false; return; + } if (playHasIllegalWords && QuackleIO::UtilSettings::self()->scoreInvalidAsZero) prettiedMove.score = 0; @@ -818,7 +824,7 @@ void TopLevel::plugIntoMatrix(View *view) { plugIntoBaseMatrix(view); - connect(view, SIGNAL(setCandidateMove(const Quackle::Move &)), this, SLOT(setCandidateMove(const Quackle::Move &))); + connect(view, SIGNAL(setCandidateMove(const Quackle::Move &, bool *)), this, SLOT(setCandidateMove(const Quackle::Move &, bool *))); connect(view, SIGNAL(removeCandidateMoves(const Quackle::MoveList &)), this, SLOT(removeCandidateMoves(const Quackle::MoveList &))); connect(view, SIGNAL(commit()), this, SLOT(commit())); connect(view, SIGNAL(setRack(const Quackle::Rack &)), this, SLOT(setRack(const Quackle::Rack &))); diff --git a/quacker/quacker.h b/quacker/quacker.h index 27bef92..31830e8 100644 --- a/quacker/quacker.h +++ b/quacker/quacker.h @@ -177,7 +177,7 @@ protected slots: void statusMessage(const QString &mesage); // set game's candidate to move and update views - void setCandidateMove(const Quackle::Move &move); + void setCandidateMove(const Quackle::Move &move, bool *carryOnPtr = nullptr); void removeCandidateMoves(const Quackle::MoveList &moves); // set current player's rack and update views diff --git a/quacker/view.cpp b/quacker/view.cpp index 13cf514..5057002 100644 --- a/quacker/view.cpp +++ b/quacker/view.cpp @@ -59,7 +59,7 @@ void View::connectSubviewSignals() for (auto& it : m_subviews) { connect(it, SIGNAL(statusMessage(const QString &)), this, SIGNAL(statusMessage(const QString &))); - connect(it, SIGNAL(setCandidateMove(const Quackle::Move &)), this, SIGNAL(setCandidateMove(const Quackle::Move &))); + connect(it, SIGNAL(setCandidateMove(const Quackle::Move &, bool *)), this, SIGNAL(setCandidateMove(const Quackle::Move &, bool *))); connect(it, SIGNAL(removeCandidateMoves(const Quackle::MoveList &)), this, SIGNAL(removeCandidateMoves(const Quackle::MoveList &))); connect(it, SIGNAL(commit()), this, SIGNAL(commit())); connect(it, SIGNAL(setRack(const Quackle::Rack &)), this, SIGNAL(setRack(const Quackle::Rack &))); diff --git a/quacker/view.h b/quacker/view.h index 2cde406..dd8f40e 100644 --- a/quacker/view.h +++ b/quacker/view.h @@ -59,7 +59,7 @@ signals: // emit to alert the rest of the application to show this // as candidate move - may eventually trigger positionChanged // in response - void setCandidateMove(const Quackle::Move &move); + void setCandidateMove(const Quackle::Move &move, bool *carryOnPtr = nullptr); void removeCandidateMoves(const Quackle::MoveList &moves); void commit(); |