gui: display victory
All checks were successful
Linux arm64 / Build (push) Successful in 58s

This commit is contained in:
2025-01-29 12:10:30 +01:00
parent 9213a10c17
commit 89653f8517
3 changed files with 21 additions and 8 deletions

View File

@@ -27,6 +27,10 @@ public class RenderableMultidoku {
this.doku = doku;
}
public boolean isResolved() {
return this.doku.isValid();
}
public int getWidth() {
return width;
}

View File

@@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import common.Signal;
import gui.ColorGenerator.Color;
import imgui.ImGui;
import imgui.ImVec2;
@@ -24,6 +25,8 @@ public class SudokuRenderer {
private static final ImVec4 TRANSPARENT = new ImVec4();
private static final ImVec2 cellSize = new ImVec2(50, 50);
public final Signal onResolve = new Signal();
public SudokuRenderer(MultiDoku doku) {
this.doku = RenderableMultidoku.fromMultidoku(doku);
this.colorPalette = initColors();
@@ -55,6 +58,8 @@ public class SudokuRenderer {
} else {
if (ImGui.button(Integer.toString(i + 1), cellSize)) {
this.doku.setCellValue(currentCell, i);
if (this.doku.isResolved())
this.onResolve.emit();
ImGui.closeCurrentPopup();
}
}
@@ -86,11 +91,8 @@ public class SudokuRenderer {
int symbol = cell.getSymbolIndex();
Color blockColor = colorPalette.get(cell.getBlock());
if (!cell.isMutable()) {
// ImGui.pushFont(Fonts.ARIAL_BOLD);
blockColor = new Color(blockColor.r - 0.20f, blockColor.g - 0.20f, blockColor.b - 0.20f);
// ImGui.pushStyleColor(ImGuiCol.Text, new ImVec4(0.1f, 0.1f, 0.1f, 1.0f));
} else {
// ImGui.pushFont(Fonts.CHERI);
}
ImGui.pushStyleColor(ImGuiCol.Button, new ImVec4(blockColor.r, blockColor.g, blockColor.b, 1.0f));
String cellText = "";
@@ -100,10 +102,6 @@ public class SudokuRenderer {
ImGui.openPopup("editPopup");
currentCell = cell;
}
if (!cell.isMutable()) {
// ImGui.popStyleColor();
}
// ImGui.popFont();
}
ImGui.popStyleColor(2);
}

View File

@@ -15,10 +15,17 @@ public class SudokuView extends BaseView {
private Thread resolveThread;
private final MultiDoku doku;
private boolean resolved = false;
public SudokuView(StateMachine stateMachine, MultiDoku doku) {
super(stateMachine);
this.doku = doku;
this.sudokuRenderer = new SudokuRenderer(doku);
this.sudokuRenderer.onResolve.connect(this::onResolve);
}
private void onResolve() {
this.resolved = true;
}
private void stopResolve() {
@@ -63,7 +70,7 @@ public class SudokuView extends BaseView {
boolean beginSolve = false;
if (centeredButton("Résoudre")) {
if (!resolved && centeredButton("Résoudre")) {
beginSolve = true;
}
if (resolveThread != null)
@@ -81,6 +88,10 @@ public class SudokuView extends BaseView {
stopResolve();
});
}
if (resolved) {
ImGui.text("Bravo !");
}
}
@Override