This commit is contained in:
@@ -31,7 +31,7 @@ public class Main extends Application {
|
||||
@Override
|
||||
protected void preRun() {
|
||||
super.preRun();
|
||||
Images.loadImages();
|
||||
Images.reloadImages();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
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 {
|
||||
@@ -14,6 +17,30 @@ public class OptionsMenu extends BaseView {
|
||||
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");
|
||||
@@ -23,6 +50,7 @@ public class OptionsMenu extends BaseView {
|
||||
if (ImGui.sliderFloat("Vitesse d'animation de l'arrière plan", backgroundSpeed, 0.0f, 10.0f)) {
|
||||
Options.BackgroundSpeed = backgroundSpeed[0];
|
||||
}
|
||||
renderImageSelectButton();
|
||||
renderReturnButton();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user