This commit is contained in:
BIN
app/INFECTED.ttf
Normal file
BIN
app/INFECTED.ttf
Normal file
Binary file not shown.
BIN
app/arial.ttf
Normal file
BIN
app/arial.ttf
Normal file
Binary file not shown.
BIN
app/arial_bold.ttf
Normal file
BIN
app/arial_bold.ttf
Normal file
Binary file not shown.
BIN
app/cheri.ttf
Normal file
BIN
app/cheri.ttf
Normal file
Binary file not shown.
22
app/src/main/java/gui/Fonts.java
Normal file
22
app/src/main/java/gui/Fonts.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package gui;
|
||||
|
||||
import imgui.ImFont;
|
||||
import imgui.ImGui;
|
||||
|
||||
public class Fonts {
|
||||
|
||||
public static ImFont ARIAL;
|
||||
public static ImFont ARIAL_BOLD;
|
||||
public static ImFont CHERI;
|
||||
public static ImFont COMIC;
|
||||
public static ImFont INFECTED;
|
||||
|
||||
public static void createFonts() {
|
||||
COMIC = ImGui.getIO().getFonts().addFontFromFileTTF("comic.ttf", 50.0f);
|
||||
ARIAL_BOLD = ImGui.getIO().getFonts().addFontFromFileTTF("arial_bold.ttf", 50.0f);
|
||||
ARIAL = ImGui.getIO().getFonts().addFontFromFileTTF("arial.ttf", 50.0f);
|
||||
CHERI = ImGui.getIO().getFonts().addFontFromFileTTF("cheri.ttf", 50.0f);
|
||||
INFECTED = ImGui.getIO().getFonts().addFontFromFileTTF("INFECTED.ttf", 50.0f);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class Main extends Application {
|
||||
@Override
|
||||
protected void initImGui(Configuration config) {
|
||||
super.initImGui(config);
|
||||
ImGui.getIO().getFonts().addFontFromFileTTF("comic.ttf", 50.0f);
|
||||
Fonts.createFonts();
|
||||
stateMachine.pushState(new MainMenu(stateMachine));
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,13 @@ public class SudokuRenderer {
|
||||
} else {
|
||||
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 = "";
|
||||
if (symbol != -1)
|
||||
@@ -76,6 +83,10 @@ public class SudokuRenderer {
|
||||
ImGui.openPopup("editPopup");
|
||||
currentCell = cell;
|
||||
}
|
||||
if (!cell.isMutable()) {
|
||||
// ImGui.popStyleColor();
|
||||
}
|
||||
// ImGui.popFont();
|
||||
}
|
||||
ImGui.popStyleColor();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ package gui.menu;
|
||||
|
||||
import imgui.ImGui;
|
||||
import imgui.type.ImInt;
|
||||
import sudoku.solver.Solver;
|
||||
import sudoku.structure.Cell;
|
||||
import sudoku.structure.MultiDoku;
|
||||
import sudoku.structure.Sudoku;
|
||||
import sudoku.structure.SudokuFactory;
|
||||
|
||||
public class SoloMenu extends BaseView {
|
||||
@@ -19,6 +23,29 @@ public class SoloMenu extends BaseView {
|
||||
super(stateMachine);
|
||||
}
|
||||
|
||||
private void pushSudokuState(MultiDoku doku, boolean empty) {
|
||||
if (!empty) {
|
||||
try {
|
||||
int level = 0;
|
||||
for (Sudoku sudoku : doku.getSubGrids()) {
|
||||
level += sudoku.getSize() * sudoku.getSize() / 10 * 3;
|
||||
}
|
||||
Solver.solve(doku);
|
||||
SudokuFactory.newDokuFromFilledOne(doku, level - 1);
|
||||
for (Sudoku sudoku : doku.getSubGrids()) {
|
||||
for (Cell cell : sudoku.getCells()) {
|
||||
if (cell.getSymbolIndex() != Cell.NOSYMBOL) {
|
||||
cell.setImmutable();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.stateMachine.pushState(new SudokuView(stateMachine, doku));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
ImGui.text("Solo");
|
||||
@@ -27,8 +54,10 @@ public class SoloMenu extends BaseView {
|
||||
case SQUARE:
|
||||
ImGui.inputInt("Taille", sudokuSize);
|
||||
if (ImGui.button("Résoudre un sudoku")) {
|
||||
this.stateMachine.pushState(new SudokuView(stateMachine,
|
||||
SudokuFactory.createBasicEmptySquareSudoku(sudokuSize.get())));
|
||||
pushSudokuState(SudokuFactory.createBasicEmptySquareSudoku(sudokuSize.get()), false);
|
||||
}
|
||||
if (ImGui.button("Générer une grille vide")) {
|
||||
pushSudokuState(SudokuFactory.createBasicEmptySquareSudoku(sudokuSize.get()), true);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -36,16 +65,23 @@ public class SoloMenu extends BaseView {
|
||||
ImGui.inputInt("Largeur", sudokuHeight);
|
||||
ImGui.inputInt("Longueur", sudokuWidth);
|
||||
if (ImGui.button("Résoudre un sudoku")) {
|
||||
this.stateMachine.pushState(new SudokuView(stateMachine,
|
||||
SudokuFactory.createBasicEmptyRectangleSudoku(sudokuWidth.get(), sudokuHeight.get())));
|
||||
pushSudokuState(
|
||||
SudokuFactory.createBasicEmptyRectangleSudoku(sudokuWidth.get(), sudokuHeight.get()),
|
||||
false);
|
||||
}
|
||||
if (ImGui.button("Générer une grille vide")) {
|
||||
pushSudokuState(
|
||||
SudokuFactory.createBasicEmptyRectangleSudoku(sudokuWidth.get(), sudokuHeight.get()), true);
|
||||
}
|
||||
break;
|
||||
|
||||
case MULTIDOKU:
|
||||
ImGui.inputInt("Taille", sudokuSize);
|
||||
if (ImGui.button("Résoudre un multidoku")) {
|
||||
this.stateMachine.pushState(new SudokuView(stateMachine,
|
||||
SudokuFactory.createBasicSquareMultidoku(sudokuSize.get())));
|
||||
if (ImGui.button("Résoudre un sudoku")) {
|
||||
pushSudokuState(SudokuFactory.createBasicSquareMultidoku(sudokuSize.get()), false);
|
||||
}
|
||||
if (ImGui.button("Générer une grille vide")) {
|
||||
pushSudokuState(SudokuFactory.createBasicSquareMultidoku(sudokuSize.get()), true);
|
||||
}
|
||||
|
||||
default:
|
||||
|
||||
@@ -18,6 +18,25 @@ public class SudokuView extends BaseView {
|
||||
super(stateMachine);
|
||||
this.doku = doku;
|
||||
this.sudokuRenderer = new SudokuRenderer(doku);
|
||||
// int level = 0;
|
||||
// for (Sudoku sudoku : this.doku.getSubGrids()) {
|
||||
// level += sudoku.getSize() * sudoku.getSize() / 10;
|
||||
// }
|
||||
// try {
|
||||
// Solver.solve(doku);
|
||||
// SudokuFactory.newDokuFromFilledOne(doku, level);
|
||||
// for (Sudoku sudoku : this.doku.getSubGrids()) {
|
||||
// for (Cell cell : sudoku.getCells()) {
|
||||
// if (cell.getSymbolIndex() != Cell.NOSYMBOL) {
|
||||
// cell.setImmutable();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// System.out.println("non ça n'arrivera pas");
|
||||
// //TODO: ça va arriver
|
||||
// }
|
||||
}
|
||||
|
||||
private void stopResolve() {
|
||||
|
||||
@@ -3,6 +3,8 @@ package sudoku.structure;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import sudoku.io.SudokuSerializer;
|
||||
|
||||
/**
|
||||
* @class MultiDoku
|
||||
* @brief Représente une grille de Multidoku.
|
||||
@@ -19,6 +21,11 @@ public class MultiDoku {
|
||||
this.subGrids = subGrids;
|
||||
}
|
||||
|
||||
public MultiDoku clone() {
|
||||
//TODO: ahhhhhhhhhhhhhhhhhhhhhhh
|
||||
return SudokuSerializer.deserializeSudoku(SudokuSerializer.serializeSudoku(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie le nombre de sudoku contenu dans ce MultiDoku.
|
||||
* @return int
|
||||
|
||||
Reference in New Issue
Block a user