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