fix multiplayer crash

This commit is contained in:
2025-02-03 11:32:17 +01:00
parent 11a246adfd
commit 7dd3f198db

View File

@@ -71,24 +71,28 @@ public class SudokuRenderer {
private void renderPopup() { private void renderPopup() {
if (ImGui.beginPopup("editPopup")) { if (ImGui.beginPopup("editPopup")) {
Block block = currentCell.getBlock(); if (currentCell == null)
int symbolCount = block.getCells().size(); ImGui.closeCurrentPopup();
for (int i = 0; i < symbolCount; i++) { else {
if ((i + 1) % (int) (Math.sqrt(symbolCount)) != 1) Block block = currentCell.getBlock();
ImGui.sameLine(); int symbolCount = block.getCells().size();
if (currentCell.getSymbolIndex() == i) { for (int i = 0; i < symbolCount; i++) {
if (ImGui.button("X", cellSize)) { if ((i + 1) % (int) (Math.sqrt(symbolCount)) != 1)
currentCell.setSymbolIndex(Cell.NOSYMBOL); ImGui.sameLine();
this.onCellChange.emit(currentCell); if (currentCell.getSymbolIndex() == i) {
ImGui.closeCurrentPopup(); if (ImGui.button("X", cellSize)) {
} currentCell.setSymbolIndex(Cell.NOSYMBOL);
} else { this.onCellChange.emit(currentCell);
if (ImGui.button(Options.Symboles.getSymbols().get(i), cellSize)) { ImGui.closeCurrentPopup();
currentCell.setSymbolIndex(i); }
this.onCellChange.emit(currentCell); } else {
if (this.doku.getDoku().isSolved()) if (ImGui.button(Options.Symboles.getSymbols().get(i), cellSize)) {
this.onResolve.emit(); currentCell.setSymbolIndex(i);
ImGui.closeCurrentPopup(); this.onCellChange.emit(currentCell);
if (this.doku.getDoku().isSolved())
this.onResolve.emit();
ImGui.closeCurrentPopup();
}
} }
} }
} }