Merge branch 'symbols'
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package gui;
|
package gui;
|
||||||
|
|
||||||
import imgui.ImFont;
|
import imgui.ImFont;
|
||||||
|
import imgui.ImFontConfig;
|
||||||
|
import imgui.ImFontGlyphRangesBuilder;
|
||||||
import imgui.ImGui;
|
import imgui.ImGui;
|
||||||
|
|
||||||
public class Fonts {
|
public class Fonts {
|
||||||
@@ -10,14 +12,22 @@ public class Fonts {
|
|||||||
public static ImFont CHERI;
|
public static ImFont CHERI;
|
||||||
public static ImFont COMIC;
|
public static ImFont COMIC;
|
||||||
public static ImFont INFECTED;
|
public static ImFont INFECTED;
|
||||||
|
public static ImFont EMOJIS;
|
||||||
|
|
||||||
private static final String baseDir = "";
|
private static final String baseDir = "";
|
||||||
|
|
||||||
public static void createFonts() {
|
public static void createFonts() {
|
||||||
|
ImFontGlyphRangesBuilder builder = new ImFontGlyphRangesBuilder();
|
||||||
|
builder.addRanges(ImGui.getIO().getFonts().getGlyphRangesDefault());
|
||||||
|
builder.addRanges(ImGui.getIO().getFonts().getGlyphRangesCyrillic());
|
||||||
|
// builder.addRanges(ImGui.getIO().getFonts().getGlyphRangesChineseFull());
|
||||||
|
ImFontConfig cfg = new ImFontConfig();
|
||||||
|
cfg.setGlyphRanges(builder.buildRanges());
|
||||||
|
|
||||||
COMIC = ImGui.getIO().getFonts().addFontFromFileTTF(baseDir + "comic.ttf", 50.0f);
|
COMIC = ImGui.getIO().getFonts().addFontFromFileTTF(baseDir + "comic.ttf", 50.0f);
|
||||||
ARIAL_BOLD = ImGui.getIO().getFonts().addFontFromFileTTF(baseDir + "arial_bold.ttf", 50.0f);
|
ARIAL_BOLD = ImGui.getIO().getFonts().addFontFromFileTTF(baseDir + "arial_bold.ttf", 50.0f);
|
||||||
ARIAL = ImGui.getIO().getFonts().addFontFromFileTTF(baseDir + "arial.ttf", 50.0f);
|
ARIAL = ImGui.getIO().getFonts().addFontFromFileTTF(baseDir + "arial.ttf", 50.0f, cfg);
|
||||||
CHERI = ImGui.getIO().getFonts().addFontFromFileTTF(baseDir + "cheri.ttf", 50.0f);
|
CHERI = ImGui.getIO().getFonts().addFontFromFileTTF(baseDir + "cheri.ttf", 50.0f);
|
||||||
INFECTED = ImGui.getIO().getFonts().addFontFromFileTTF(baseDir + "INFECTED.ttf", 50.0f);
|
INFECTED = ImGui.getIO().getFonts().addFontFromFileTTF(baseDir + "INFECTED.ttf", 50.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
7
app/src/main/java/gui/Options.java
Normal file
7
app/src/main/java/gui/Options.java
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package gui;
|
||||||
|
|
||||||
|
public class Options {
|
||||||
|
|
||||||
|
public static Symbols Symboles = Symbols.Numbers;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -76,10 +76,12 @@ public class SudokuRenderer {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ImGui.button(Integer.toString(i + 1), cellSize)) {
|
if (ImGui.button(Integer.toString(i + 1), cellSize)) {
|
||||||
currentCell.trySetValue(i);
|
if (ImGui.button(Options.Symboles.getSymbols().get(i), cellSize)) {
|
||||||
if (this.doku.getDoku().isSolved())
|
currentCell.trySetValue(i);
|
||||||
this.onResolve.emit();
|
if (this.doku.getDoku().isSolved())
|
||||||
ImGui.closeCurrentPopup();
|
this.onResolve.emit();
|
||||||
|
ImGui.closeCurrentPopup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,6 +90,9 @@ public class SudokuRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void render() {
|
public void render() {
|
||||||
|
if (Options.Symboles == Symbols.Russian) {
|
||||||
|
ImGui.pushFont(Fonts.ARIAL);
|
||||||
|
}
|
||||||
final float sudokuViewWidth = cellSize.x * doku.getWidth();
|
final float sudokuViewWidth = cellSize.x * doku.getWidth();
|
||||||
final float displayWidth = ImGui.getIO().getDisplaySizeX();
|
final float displayWidth = ImGui.getIO().getDisplaySizeX();
|
||||||
float offsetX = displayWidth / 2.0f - sudokuViewWidth / 2.0f;
|
float offsetX = displayWidth / 2.0f - sudokuViewWidth / 2.0f;
|
||||||
@@ -123,7 +128,7 @@ public class SudokuRenderer {
|
|||||||
ImGui.pushStyleColor(ImGuiCol.Button, new ImVec4(blockColor.r, blockColor.g, blockColor.b, 1.0f));
|
ImGui.pushStyleColor(ImGuiCol.Button, new ImVec4(blockColor.r, blockColor.g, blockColor.b, 1.0f));
|
||||||
String cellText = "";
|
String cellText = "";
|
||||||
if (symbol != -1)
|
if (symbol != -1)
|
||||||
cellText += Integer.toString(symbol + 1);
|
cellText += Options.Symboles.getSymbols().get(cell.getSymbolIndex());
|
||||||
if (ImGui.button(cellText + "##" + index, cellSize) && cell.isMutable()) {
|
if (ImGui.button(cellText + "##" + index, cellSize) && cell.isMutable()) {
|
||||||
ImGui.openPopup("editPopup");
|
ImGui.openPopup("editPopup");
|
||||||
currentCell = cell;
|
currentCell = cell;
|
||||||
@@ -135,6 +140,9 @@ public class SudokuRenderer {
|
|||||||
ImGui.popStyleVar(2);
|
ImGui.popStyleVar(2);
|
||||||
renderPopup();
|
renderPopup();
|
||||||
ImGui.endChild();
|
ImGui.endChild();
|
||||||
|
if (Options.Symboles == Symbols.Russian) {
|
||||||
|
ImGui.popFont();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
83
app/src/main/java/gui/Symbols.java
Normal file
83
app/src/main/java/gui/Symbols.java
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
package gui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public enum Symbols {
|
||||||
|
|
||||||
|
Numbers("Nombres", getNumbers()),
|
||||||
|
Letters("Lettres", getLetters()),
|
||||||
|
Russian("Cyrilique", getRussian()),
|
||||||
|
Emojis("Emojis (Console uniquement)", getEmojis());
|
||||||
|
|
||||||
|
String displayName;
|
||||||
|
List<String> symbols;
|
||||||
|
|
||||||
|
private Symbols(String displayName, List<String> symbols) {
|
||||||
|
this.symbols = symbols;
|
||||||
|
this.displayName = displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplayName() {
|
||||||
|
return displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getSymbols() {
|
||||||
|
return symbols;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> getNumbers() {
|
||||||
|
List<String> sym = new ArrayList<>();
|
||||||
|
for (int i = 1; i <= 100; i++) {
|
||||||
|
sym.add(Integer.toString(i));
|
||||||
|
}
|
||||||
|
return sym;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> getLetters() {
|
||||||
|
List<String> sym = new ArrayList<>();
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
int currentOffset = i;
|
||||||
|
String letter = "";
|
||||||
|
while (currentOffset >= 26) {
|
||||||
|
letter += Character.toString((char) ('A' + currentOffset % 26));
|
||||||
|
currentOffset /= 26;
|
||||||
|
currentOffset--;
|
||||||
|
}
|
||||||
|
letter += Character.toString((char) ('A' + currentOffset % 26));
|
||||||
|
sym.add(new StringBuilder(letter).reverse().toString());
|
||||||
|
}
|
||||||
|
return sym;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> getRussian() {
|
||||||
|
List<String> sym = new ArrayList<>();
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
sym.add(new String(Character.toChars(0X0400 + i)));
|
||||||
|
}
|
||||||
|
return sym;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> getEmojis() {
|
||||||
|
List<String> sym = new ArrayList<>();
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
sym.add(new String(Character.toChars(0X1F600 + i)));
|
||||||
|
}
|
||||||
|
return sym;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String[] symbolNames;
|
||||||
|
|
||||||
|
static {
|
||||||
|
Symbols[] symbols = Symbols.values();
|
||||||
|
symbolNames = new String[symbols.length];
|
||||||
|
for (int i = 0; i < symbols.length; i++) {
|
||||||
|
symbolNames[i] = symbols[i].getDisplayName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getSymbolsNames() {
|
||||||
|
return symbolNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,17 +1,24 @@
|
|||||||
package gui.menu;
|
package gui.menu;
|
||||||
|
|
||||||
|
import gui.Options;
|
||||||
|
import gui.Symbols;
|
||||||
import imgui.ImGui;
|
import imgui.ImGui;
|
||||||
|
import imgui.type.ImInt;
|
||||||
|
|
||||||
public class OptionsMenu extends BaseView {
|
public class OptionsMenu extends BaseView {
|
||||||
|
|
||||||
|
private ImInt currentValue = new ImInt();
|
||||||
|
|
||||||
public OptionsMenu(StateMachine stateMachine) {
|
public OptionsMenu(StateMachine stateMachine) {
|
||||||
super(stateMachine);
|
super(stateMachine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render() {
|
public void render() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
ImGui.text("Options");
|
ImGui.text("Options");
|
||||||
|
if(ImGui.combo("Jeu de symboles", currentValue, Symbols.getSymbolsNames())){
|
||||||
|
Options.Symboles = Symbols.values()[currentValue.get()];
|
||||||
|
}
|
||||||
renderReturnButton();
|
renderReturnButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user