This commit is contained in:
17
app/src/main/java/gui/menu/CreateGameMenu.java
Normal file
17
app/src/main/java/gui/menu/CreateGameMenu.java
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package gui.menu;
|
||||||
|
|
||||||
|
import imgui.ImGui;
|
||||||
|
|
||||||
|
public class CreateGameMenu extends BaseView {
|
||||||
|
|
||||||
|
public CreateGameMenu(StateMachine stateMachine) {
|
||||||
|
super(stateMachine);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render() {
|
||||||
|
ImGui.text("Créer");
|
||||||
|
renderReturnButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
17
app/src/main/java/gui/menu/JoinGameMenu.java
Normal file
17
app/src/main/java/gui/menu/JoinGameMenu.java
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package gui.menu;
|
||||||
|
|
||||||
|
import imgui.ImGui;
|
||||||
|
|
||||||
|
public class JoinGameMenu extends BaseView {
|
||||||
|
|
||||||
|
public JoinGameMenu(StateMachine stateMachine) {
|
||||||
|
super(stateMachine);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render() {
|
||||||
|
ImGui.text("Rejoindre");
|
||||||
|
renderReturnButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,18 +1,56 @@
|
|||||||
package gui.menu;
|
package gui.menu;
|
||||||
|
|
||||||
import imgui.ImGui;
|
import imgui.ImGui;
|
||||||
|
import imgui.ImVec2;
|
||||||
|
import imgui.type.ImInt;
|
||||||
|
import imgui.type.ImString;
|
||||||
|
|
||||||
public class MultiMenu extends BaseView {
|
public class MultiMenu extends BaseView {
|
||||||
|
|
||||||
|
private final ImInt port = new ImInt(25565);
|
||||||
|
private final ImString address = new ImString("localhost");
|
||||||
|
|
||||||
public MultiMenu(StateMachine stateMachine) {
|
public MultiMenu(StateMachine stateMachine) {
|
||||||
super(stateMachine);
|
super(stateMachine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void renderCreate() {
|
||||||
|
ImVec2 displaySize = ImGui.getIO().getDisplaySize();
|
||||||
|
ImGui.beginChild("##CreateGame", new ImVec2(displaySize.x / 2.0f, displaySize.y * 8.0f / 9.0f));
|
||||||
|
ImGui.inputInt("Port", port);
|
||||||
|
if (ImGui.button("Créer")) {
|
||||||
|
// TODO: create game
|
||||||
|
}
|
||||||
|
ImGui.endChild();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderJoin() {
|
||||||
|
ImVec2 displaySize = ImGui.getIO().getDisplaySize();
|
||||||
|
ImGui.beginChild("##JoinGame", new ImVec2(displaySize.x / 2.0f, displaySize.y * 8.0f / 9.0f));
|
||||||
|
ImGui.inputText("Adresse", address);
|
||||||
|
ImGui.inputInt("Port", port);
|
||||||
|
if (ImGui.button("Rejoindre")) {
|
||||||
|
// TODO: join game
|
||||||
|
}
|
||||||
|
ImGui.endChild();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render() {
|
public void render() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
ImGui.text("Multi");
|
renderCreate();
|
||||||
renderReturnButton();
|
ImGui.sameLine();
|
||||||
|
renderJoin();
|
||||||
|
|
||||||
|
ImVec2 displaySize = ImGui.getIO().getDisplaySize();
|
||||||
|
ImVec2 buttonSize = new ImVec2(500, 70.0f);
|
||||||
|
|
||||||
|
float centerX = displaySize.x / 2.0f - buttonSize.x / 2.0f;
|
||||||
|
|
||||||
|
ImGui.setCursorPosX(centerX);
|
||||||
|
if (ImGui.button("Retour", buttonSize)) {
|
||||||
|
closeMenu();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,45 @@
|
|||||||
package gui.menu;
|
package gui.menu;
|
||||||
|
|
||||||
import imgui.ImGui;
|
import imgui.ImGui;
|
||||||
|
import imgui.type.ImInt;
|
||||||
|
|
||||||
public class SoloMenu extends BaseView {
|
public class SoloMenu extends BaseView {
|
||||||
|
|
||||||
|
private final ImInt sudokuType = new ImInt(0);
|
||||||
|
private static final String[] sudokuTypes = { "Carré", "Rectangle" };
|
||||||
|
private static final int SQUARE = 0, RECTANGLE = 1;
|
||||||
|
|
||||||
|
private final ImInt sudokuSize = new ImInt(3);
|
||||||
|
|
||||||
|
private final ImInt sudokuWidth = new ImInt(3);
|
||||||
|
private final ImInt sudokuHeight = new ImInt(3);
|
||||||
|
|
||||||
public SoloMenu(StateMachine stateMachine) {
|
public SoloMenu(StateMachine stateMachine) {
|
||||||
super(stateMachine);
|
super(stateMachine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render() {
|
public void render() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
ImGui.text("Solo");
|
ImGui.text("Solo");
|
||||||
|
ImGui.combo("Type de Sudoku", sudokuType, sudokuTypes);
|
||||||
|
switch (sudokuType.get()) {
|
||||||
|
case SQUARE:
|
||||||
|
ImGui.inputInt("Taille", sudokuSize);
|
||||||
if (ImGui.button("Résoudre un sudoku")) {
|
if (ImGui.button("Résoudre un sudoku")) {
|
||||||
this.stateMachine.pushState(new SudokuView(stateMachine, 3));
|
this.stateMachine.pushState(new SudokuView(stateMachine, sudokuSize.get(), sudokuSize.get()));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RECTANGLE:
|
||||||
|
ImGui.inputInt("Largeur", sudokuHeight);
|
||||||
|
ImGui.inputInt("Longueur", sudokuWidth);
|
||||||
|
if (ImGui.button("Résoudre un sudoku")) {
|
||||||
|
this.stateMachine.pushState(new SudokuView(stateMachine, sudokuWidth.get(), sudokuHeight.get()));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
renderReturnButton();
|
renderReturnButton();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.util.Stack;
|
|||||||
|
|
||||||
import imgui.ImGui;
|
import imgui.ImGui;
|
||||||
import imgui.ImVec2;
|
import imgui.ImVec2;
|
||||||
|
import imgui.flag.ImGuiKey;
|
||||||
import imgui.flag.ImGuiWindowFlags;
|
import imgui.flag.ImGuiWindowFlags;
|
||||||
|
|
||||||
public class StateMachine {
|
public class StateMachine {
|
||||||
@@ -22,6 +23,12 @@ public class StateMachine {
|
|||||||
menus.pop();
|
menus.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkEscape() {
|
||||||
|
if (ImGui.isKeyPressed(ImGuiKey.Escape) && menus.size() > 1) {
|
||||||
|
popState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void render() {
|
public void render() {
|
||||||
var displaySize = ImGui.getIO().getDisplaySize();
|
var displaySize = ImGui.getIO().getDisplaySize();
|
||||||
ImGui.setNextWindowPos(new ImVec2(0.0f, 0.0f));
|
ImGui.setNextWindowPos(new ImVec2(0.0f, 0.0f));
|
||||||
@@ -30,6 +37,7 @@ public class StateMachine {
|
|||||||
| ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoBackground);
|
| ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoBackground);
|
||||||
menus.getLast().render();
|
menus.getLast().render();
|
||||||
ImGui.end();
|
ImGui.end();
|
||||||
|
checkEscape();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ public class SudokuView extends BaseView {
|
|||||||
private int currentIndex = -1;
|
private int currentIndex = -1;
|
||||||
private final Map<Block, Color> colorPalette;
|
private final Map<Block, Color> colorPalette;
|
||||||
|
|
||||||
public SudokuView(StateMachine stateMachine, int size) {
|
public SudokuView(StateMachine stateMachine, int width, int height) {
|
||||||
super(stateMachine);
|
super(stateMachine);
|
||||||
MultiDoku doku = SudokuFactory.createBasicEmptySquareSudoku(size);
|
MultiDoku doku = SudokuFactory.createBasicEmptyRectangleSudoku(width, height);
|
||||||
this.sudoku = doku.getSubGrid(0);
|
this.sudoku = doku.getSubGrid(0);
|
||||||
this.colorPalette = new HashMap<>();
|
this.colorPalette = new HashMap<>();
|
||||||
initColors();
|
initColors();
|
||||||
@@ -78,6 +78,9 @@ public class SudokuView extends BaseView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
renderPopup();
|
renderPopup();
|
||||||
|
if (ImGui.button("Résoudre")) {
|
||||||
|
// TODO: solve
|
||||||
|
}
|
||||||
renderReturnButton();
|
renderReturnButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user