feat: various ui changes
Some checks failed
Linux arm64 / Build (push) Has been cancelled

This commit is contained in:
2025-01-28 14:56:06 +01:00
parent f489c4c8ab
commit 944f2c0596
10 changed files with 103 additions and 8 deletions

BIN
app/INFECTED.ttf Normal file

Binary file not shown.

BIN
app/arial.ttf Normal file

Binary file not shown.

BIN
app/arial_bold.ttf Normal file

Binary file not shown.

BIN
app/cheri.ttf Normal file

Binary file not shown.

View 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);
}
}

View File

@@ -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));
}

View File

@@ -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();
}

View File

@@ -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:

View File

@@ -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() {

View File

@@ -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