Skip to content

Commit

Permalink
Simplified the Show all Candidate prompt
Browse files Browse the repository at this point in the history
The previous prompt message was too lengthy, and the button choice was counter intuitive.
  • Loading branch information
PseudoFish committed Jan 19, 2020
1 parent 65134d2 commit 261bb75
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ international support.
Change log
==========

Version 2.3.2 (WIP)
-------------------

Minor:
- Replaced Active Cell's Remove Candidate functionality with Toggle Candidate.
- This feature now works even if Show all Candidates is off.
- Simplified the prompt when Show all Candidates is turned on.

Version 2.3.1 (2020-01-13)
--------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/intl/MainFrame.properties
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ MainFrame.copySSMenuItem.text=Copy for SimpleSudoku
MainFrame.copySSMenuItem.mnemonic=i
MainFrame.savePuzzleMenuItem.text=Save Puzzle
MainFrame.savePuzzleMenuItem.mnemonic=v
MainFrame.candidatesMissing=Necessary candidates are missing. Do you want to automatically add them\n(choosing "No" shows all possible candidates, your eliminations will be lost)?
MainFrame.candidatesMissing=Your candidate eliminations will be reset. Are you sure?
MainFrame.showColorKuMenuItem.text=Show ColorKu
MainFrame.showColorKuMenuItem.mnemonic=c
MainFrame.raetselMenu.text=Puzzle
Expand Down
2 changes: 1 addition & 1 deletion src/intl/MainFrame_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ MainFrame.copySSMenuItem.text=F\u00fcr SimpleSudoku kopieren
MainFrame.copySSMenuItem.mnemonic=m
MainFrame.savePuzzleMenuItem.text=Sudoku speichern
MainFrame.savePuzzleMenuItem.mnemonic=p
MainFrame.candidatesMissing=Notwendige Kandidaten fehlen. Sollen sie automatisch erg\u00e4nzt werden\n("Nein" zeigt alle m\u00f6glichen Kandidaten, bereits durchgef\u00fchrte\nEliminierungen werden verworfen)?
MainFrame.candidatesMissing=Die Eliminierungen Ihrer Kandidaten werden zurückgesetzt. Bist du sicher?
MainFrame.showColorKuMenuItem.text=ColorKu anzeigen
MainFrame.showColorKuMenuItem.mnemonic=c
MainFrame.raetselMenu.text=R\u00e4tsel
Expand Down
17 changes: 10 additions & 7 deletions src/sudoku/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -2516,16 +2516,16 @@ private void showCandidatesMenuItemActionPerformed(java.awt.event.ActionEvent ev
// if no user candidates have been set, the internal flag is just toggled.
// if user candidates have been set, further checks have to be made
if (sudokuPanel.getSudoku().userCandidatesEmpty()) {
// just set the flag and be done!
// just set the flag and be done!
sudokuPanel.setShowCandidates(showCandidatesMenuItem.isSelected());

} else {
// display a dialog, that lets the user choose, what to do
boolean doYes = true;
if (!sudokuPanel.getSudoku().checkUserCands()) {
// necessary candidates are missing!
int ret = JOptionPane.showConfirmDialog(null,
java.util.ResourceBundle.getBundle("intl/MainFrame")
.getString("MainFrame.candidatesMissing"),
java.util.ResourceBundle.getBundle("intl/MainFrame").getString("MainFrame.candidatesMissing"),
java.util.ResourceBundle.getBundle("intl/MainFrame").getString("MainFrame.error"),
JOptionPane.YES_NO_CANCEL_OPTION);
if (ret == JOptionPane.CANCEL_OPTION) {
Expand All @@ -2542,16 +2542,19 @@ private void showCandidatesMenuItemActionPerformed(java.awt.event.ActionEvent ev

if (doYes) {
// retain all changes to the user candidates
sudokuPanel.getSudoku().switchToAllCandidates();
sudokuPanel.getSudoku().resetCandidates();
//sudokuPanel.getSudoku().rebuildAllCandidates();
sudokuPanel.getSolver().setSudoku(sudokuPanel.getSudoku());
sudokuPanel.checkProgress();
sudokuPanel.setShowCandidates(showCandidatesMenuItem.isSelected());
boolean showCandidates = showCandidatesMenuItem.isSelected();
sudokuPanel.setShowCandidates(showCandidates);
/*
} else {
// revert all changes
sudokuPanel.getSudoku().rebuildAllCandidates();
sudokuPanel.getSudoku().switchToAllCandidates();
sudokuPanel.getSolver().setSudoku(sudokuPanel.getSudoku());
sudokuPanel.checkProgress();
sudokuPanel.setShowCandidates(showCandidatesMenuItem.isSelected());
sudokuPanel.setShowCandidates(showCandidatesMenuItem.isSelected());*/
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sudoku/SudokuPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -4008,7 +4008,7 @@ public void toggleCandidateFromCellSelection(int candidate) {
for (int index : cellSelection) {
if (sudoku.getValue(index) == 0) {
boolean isCandidateOn = sudoku.isCandidate(index, candidate, !showCandidates);
sudoku.setCandidate(index, candidate, !isCandidateOn, true);
sudoku.setCandidate(index, candidate, !isCandidateOn, !showCandidates);
}
}
}
Expand Down

0 comments on commit 261bb75

Please sign in to comment.