Fixes #2
All checks were successful
Linux arm64 / Build (push) Successful in 42s

This commit is contained in:
2025-01-29 11:05:15 +01:00
parent aa86e9b956
commit ec36e19c4e
2 changed files with 36 additions and 32 deletions

View File

@@ -5,6 +5,7 @@ import java.util.concurrent.CancellationException;
import gui.SudokuRenderer;
import imgui.ImGui;
import imgui.ImGuiStyle;
import sudoku.solver.Solver;
import sudoku.structure.MultiDoku;
@@ -18,25 +19,6 @@ public class SudokuView extends BaseView {
super(stateMachine);
this.doku = doku;
this.sudokuRenderer = new SudokuRenderer(doku);
// int level = 0;
// for (Sudoku sudoku : this.doku.getSubGrids()) {
// level += sudoku.getSize() * sudoku.getSize() / 10;
// }
// try {
// Solver.solve(doku);
// SudokuFactory.newDokuFromFilledOne(doku, level);
// for (Sudoku sudoku : this.doku.getSubGrids()) {
// for (Cell cell : sudoku.getCells()) {
// if (cell.getSymbolIndex() != Cell.NOSYMBOL) {
// cell.setImmutable();
// }
// }
// }
// } catch (Exception e) {
// e.printStackTrace();
// System.out.println("non ça n'arrivera pas");
// //TODO: ça va arriver
// }
}
private void stopResolve() {
@@ -46,11 +28,24 @@ public class SudokuView extends BaseView {
}
}
boolean centeredButton(String label) {
ImGuiStyle style = ImGui.getStyle();
float size = ImGui.calcTextSizeX(label) + style.getFramePaddingX() * 2.0f;
float avail = ImGui.getContentRegionAvailX();
float off = (avail - size) * 0.5f;
if (off > 0.0f)
ImGui.setCursorPosX(ImGui.getCursorPosX() + off);
return ImGui.button(label);
}
private void renderCancelButton() {
boolean wantsToStop = false;
if (resolveThread != null && resolveThread.isAlive()) {
// ImGui.endDisabled();
if (ImGui.button("Annuler")) {
if (centeredButton("Annuler")) {
// we can't stop the Thread right now
wantsToStop = true;
}
@@ -67,8 +62,8 @@ public class SudokuView extends BaseView {
ImGui.beginDisabled();
boolean beginSolve = false;
if (ImGui.button("Résoudre")) {
if (centeredButton("Résoudre")) {
beginSolve = true;
}
if (resolveThread != null)