Fixes #28
All checks were successful
Linux arm64 / Build (push) Successful in 41s

This commit is contained in:
2025-02-02 10:35:00 +01:00
parent 06efbf649b
commit 68021b796b
4 changed files with 35 additions and 6 deletions

View File

@@ -31,7 +31,7 @@ public class Main extends Application {
@Override
protected void preRun() {
super.preRun();
Images.loadImages();
Images.reloadImages();
}
@Override

View File

@@ -32,8 +32,8 @@ public class Images {
return textureID;
}
public static void loadImages() {
BACKGROUND = loadTexture("background.png");
public static void reloadImages() {
BACKGROUND = loadTexture(Options.BackgroundPath);
}
}

View File

@@ -4,5 +4,6 @@ public class Options {
public static Symbols Symboles = Symbols.Numbers;
public static float BackgroundSpeed = 1.0f;
public static String BackgroundPath = "background.png";
}

View File

@@ -1,28 +1,56 @@
package gui.menu;
import gui.constants.Images;
import gui.constants.Options;
import gui.constants.Symbols;
import imgui.ImGui;
import imgui.extension.imguifiledialog.ImGuiFileDialog;
import imgui.extension.imguifiledialog.flag.ImGuiFileDialogFlags;
import imgui.type.ImInt;
public class OptionsMenu extends BaseView {
private ImInt currentValue = new ImInt();
private float backgroundSpeed[] = new float[]{Options.BackgroundSpeed};
private float backgroundSpeed[] = new float[] { Options.BackgroundSpeed };
public OptionsMenu(StateMachine stateMachine) {
super(stateMachine);
}
private void renderImageSelectDialog() {
if (ImGuiFileDialog.display("browse-img", ImGuiFileDialogFlags.None)) {
if (ImGuiFileDialog.isOk()) {
var selection = ImGuiFileDialog.getSelection();
for (var entry : selection.entrySet()) {
try {
String filePath = entry.getValue();
Options.BackgroundPath = filePath;
Images.reloadImages();
} catch (Exception e) {
e.printStackTrace();
}
}
}
ImGuiFileDialog.close();
}
}
private void renderImageSelectButton() {
if (ImGui.button("Changer de fond d'écran"))
ImGuiFileDialog.openDialog("browse-img", "Choisissez un fichier", ".png,.jpg,.jpeg", ".");
renderImageSelectDialog();
}
@Override
public void render() {
ImGui.text("Options");
if(ImGui.combo("Jeu de symboles", currentValue, Symbols.getSymbolsNames())){
if (ImGui.combo("Jeu de symboles", currentValue, Symbols.getSymbolsNames())) {
Options.Symboles = Symbols.values()[currentValue.get()];
}
if(ImGui.sliderFloat("Vitesse d'animation de l'arrière plan", backgroundSpeed, 0.0f, 10.0f)){
if (ImGui.sliderFloat("Vitesse d'animation de l'arrière plan", backgroundSpeed, 0.0f, 10.0f)) {
Options.BackgroundSpeed = backgroundSpeed[0];
}
renderImageSelectButton();
renderReturnButton();
}