This commit is contained in:
@@ -22,6 +22,8 @@ public class SudokuView extends BaseView {
|
||||
private String lastSavePath = null;
|
||||
|
||||
private boolean resolved = false;
|
||||
// if the solver can't solve
|
||||
private volatile boolean unresolved = false;
|
||||
|
||||
public SudokuView(StateMachine stateMachine, MultiDoku doku) {
|
||||
super(stateMachine);
|
||||
@@ -80,10 +82,16 @@ public class SudokuView extends BaseView {
|
||||
}
|
||||
}
|
||||
|
||||
private void renderUnsolvableText() {
|
||||
if (this.unresolved)
|
||||
ImGui.text("Impossible de résoudre avec l'algorithme actuel !");
|
||||
|
||||
}
|
||||
|
||||
private void startSolve(Solver solver) {
|
||||
resolveThread = new Thread(() -> {
|
||||
try {
|
||||
solver.solve(this.doku);
|
||||
unresolved = !solver.solve(this.doku);
|
||||
} catch (CancellationException e) {
|
||||
System.out.println("The user is bored !");
|
||||
}
|
||||
@@ -91,6 +99,11 @@ public class SudokuView extends BaseView {
|
||||
});
|
||||
}
|
||||
|
||||
private void renderResolvedText() {
|
||||
if (this.resolved)
|
||||
ImGui.text("Bravo !");
|
||||
}
|
||||
|
||||
private void renderSolvePopup() {
|
||||
if (ImGui.beginPopup("solve")) {
|
||||
if (ImGui.button("Résoudre avec backtrace")) {
|
||||
@@ -120,9 +133,8 @@ public class SudokuView extends BaseView {
|
||||
if (resolveThread != null)
|
||||
ImGui.endDisabled();
|
||||
|
||||
if (this.resolved) {
|
||||
ImGui.text("Bravo !");
|
||||
}
|
||||
renderResolvedText();
|
||||
renderUnsolvableText();
|
||||
|
||||
renderSolvePopup();
|
||||
}
|
||||
@@ -140,7 +152,7 @@ public class SudokuView extends BaseView {
|
||||
}
|
||||
|
||||
private void renderClearButton() {
|
||||
if(centeredButton("Effacer")){
|
||||
if (centeredButton("Effacer")) {
|
||||
this.doku.clearMutableCells();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user