This commit is contained in:
@@ -39,6 +39,8 @@ public class SudokuSelector {
|
|||||||
|
|
||||||
private final SmoothProgressBar genProgressBar;
|
private final SmoothProgressBar genProgressBar;
|
||||||
|
|
||||||
|
private volatile boolean genDone = false;
|
||||||
|
|
||||||
public SudokuSelector(boolean canGenEmptyGrid, String confirmMessage) {
|
public SudokuSelector(boolean canGenEmptyGrid, String confirmMessage) {
|
||||||
this.canGenEmptyGrid = canGenEmptyGrid;
|
this.canGenEmptyGrid = canGenEmptyGrid;
|
||||||
this.confirmMessage = confirmMessage;
|
this.confirmMessage = confirmMessage;
|
||||||
@@ -74,6 +76,8 @@ public class SudokuSelector {
|
|||||||
int filled = this.doku.getFilledCells().size();
|
int filled = this.doku.getFilledCells().size();
|
||||||
int total = this.doku.getCells().size();
|
int total = this.doku.getCells().size();
|
||||||
this.genProgressBar.render(filled / (float) total);
|
this.genProgressBar.render(filled / (float) total);
|
||||||
|
if (genDone)
|
||||||
|
ImGui.closeCurrentPopup();
|
||||||
ImGui.endPopup();
|
ImGui.endPopup();
|
||||||
} else {
|
} else {
|
||||||
stopGenThread();
|
stopGenThread();
|
||||||
@@ -82,12 +86,14 @@ public class SudokuSelector {
|
|||||||
|
|
||||||
private void selectSudoku(MultiDoku doku, boolean empty) {
|
private void selectSudoku(MultiDoku doku, boolean empty) {
|
||||||
this.doku = doku;
|
this.doku = doku;
|
||||||
|
this.genDone = false;
|
||||||
ImGui.openPopup("genProgress");
|
ImGui.openPopup("genProgress");
|
||||||
this.genThread = new Thread(() -> {
|
this.genThread = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
if (!empty) {
|
if (!empty) {
|
||||||
SudokuFactory.fillDoku(doku, Difficulty.values()[difficulty.get()]);
|
SudokuFactory.fillDoku(doku, Difficulty.values()[difficulty.get()]);
|
||||||
}
|
}
|
||||||
|
this.genDone = true;
|
||||||
this.onSelect.emit(this.doku);
|
this.onSelect.emit(this.doku);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
Reference in New Issue
Block a user