This commit is contained in:
@@ -26,16 +26,16 @@ public class SudokuSelector {
|
||||
private final ImInt difficulty = new ImInt(Difficulty.Medium.ordinal());
|
||||
private final List<ImBoolean> contraints = new ArrayList<>();
|
||||
|
||||
private static final String[] sudokuTypes = { "Carré", "Rectangle", "Multidoku" };
|
||||
private static final int SQUARE = 0, RECTANGLE = 1, MULTIDOKU = 2;
|
||||
|
||||
private final ImInt sudokuSize = new ImInt(3);
|
||||
|
||||
private final ImInt sudokuWidth = new ImInt(3);
|
||||
private final ImInt sudokuHeight = new ImInt(3);
|
||||
|
||||
public SudokuSelector(boolean canGenEmptyGrid) {
|
||||
private final String confirmMessage;
|
||||
|
||||
public SudokuSelector(boolean canGenEmptyGrid, String confirmMessage) {
|
||||
this.canGenEmptyGrid = canGenEmptyGrid;
|
||||
this.confirmMessage = confirmMessage;
|
||||
initConstraints();
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class SudokuSelector {
|
||||
switch (currentType.getMakerParamCount()) {
|
||||
case 1:
|
||||
ImGui.inputInt("Taille", sudokuSize);
|
||||
if (ImGui.button("Résoudre un sudoku")) {
|
||||
if (ImGui.button(confirmMessage)) {
|
||||
selectSudoku(currentType.createDoku(getConstraints(), sudokuSize.get()), false);
|
||||
}
|
||||
if (canGenEmptyGrid && ImGui.button("Générer une grille vide")) {
|
||||
@@ -109,7 +109,7 @@ public class SudokuSelector {
|
||||
case 2:
|
||||
ImGui.inputInt("Largeur", sudokuHeight);
|
||||
ImGui.inputInt("Longueur", sudokuWidth);
|
||||
if (ImGui.button("Résoudre un sudoku")) {
|
||||
if (ImGui.button(confirmMessage)) {
|
||||
selectSudoku(currentType.createDoku(getConstraints(), sudokuWidth.get(), sudokuHeight.get()),
|
||||
false);
|
||||
}
|
||||
|
||||
@@ -1,24 +1,27 @@
|
||||
package gui.menu;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import game.Player;
|
||||
import gui.SudokuSelector;
|
||||
import imgui.ImGui;
|
||||
import network.client.Client;
|
||||
import network.server.Server;
|
||||
import sudoku.constraint.Constraint;
|
||||
import sudoku.structure.MultiDoku;
|
||||
import sudoku.structure.SudokuFactory;
|
||||
|
||||
public class MultiPlayerView extends BaseView {
|
||||
|
||||
private final Client client;
|
||||
private final Server server;
|
||||
|
||||
private final SudokuSelector selector;
|
||||
|
||||
private MultiDoku doku = null;
|
||||
|
||||
public MultiPlayerView(StateMachine stateMachine, Client client, Server server) {
|
||||
super(stateMachine);
|
||||
this.client = client;
|
||||
this.server = server;
|
||||
this.selector = new SudokuSelector(false, "Sélectionner le sudoku");
|
||||
this.selector.onSelect.connect(this::onSelected);
|
||||
this.client.onDisconnect.connect(this::onDisconnect);
|
||||
this.client.onGameStarted
|
||||
.connect(() -> this.stateMachine.pushState(new MultiPlayerDokuView(stateMachine, client, server)));
|
||||
@@ -34,15 +37,22 @@ public class MultiPlayerView extends BaseView {
|
||||
this.stateMachine.popState();
|
||||
}
|
||||
|
||||
private void onSelected() {
|
||||
this.doku = this.selector.getDoku();
|
||||
}
|
||||
|
||||
public void renderGameStatus() {
|
||||
if (this.server == null) {
|
||||
ImGui.text("En attente de l'administrateur du serveur ...");
|
||||
} else {
|
||||
if (this.doku == null)
|
||||
ImGui.beginDisabled();
|
||||
if (ImGui.button("Démarrer")) {
|
||||
// temp
|
||||
MultiDoku doku = SudokuFactory.createBasicXShapedMultidoku(3, Arrays.asList(Constraint.Diagonal));
|
||||
this.server.startGame(doku);
|
||||
this.server.startGame(this.doku);
|
||||
}
|
||||
if (this.doku == null)
|
||||
ImGui.endDisabled();
|
||||
selector.render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ public class SoloMenu extends BaseView {
|
||||
|
||||
public SoloMenu(StateMachine stateMachine) {
|
||||
super(stateMachine);
|
||||
this.sudokuSelector = new SudokuSelector(true);
|
||||
this.sudokuSelector = new SudokuSelector(true, "Résoudre le sudoku");
|
||||
this.sudokuSelector.onSelect.connect(this::pushSudokuState);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user