This commit is contained in:
@@ -31,7 +31,7 @@ public class Main extends Application {
|
|||||||
@Override
|
@Override
|
||||||
protected void preRun() {
|
protected void preRun() {
|
||||||
super.preRun();
|
super.preRun();
|
||||||
Images.loadImages();
|
Images.reloadImages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ public class Images {
|
|||||||
return textureID;
|
return textureID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadImages() {
|
public static void reloadImages() {
|
||||||
BACKGROUND = loadTexture("background.png");
|
BACKGROUND = loadTexture(Options.BackgroundPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,5 +4,6 @@ public class Options {
|
|||||||
|
|
||||||
public static Symbols Symboles = Symbols.Numbers;
|
public static Symbols Symboles = Symbols.Numbers;
|
||||||
public static float BackgroundSpeed = 1.0f;
|
public static float BackgroundSpeed = 1.0f;
|
||||||
|
public static String BackgroundPath = "background.png";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package gui.menu;
|
package gui.menu;
|
||||||
|
|
||||||
|
import gui.constants.Images;
|
||||||
import gui.constants.Options;
|
import gui.constants.Options;
|
||||||
import gui.constants.Symbols;
|
import gui.constants.Symbols;
|
||||||
import imgui.ImGui;
|
import imgui.ImGui;
|
||||||
|
import imgui.extension.imguifiledialog.ImGuiFileDialog;
|
||||||
|
import imgui.extension.imguifiledialog.flag.ImGuiFileDialogFlags;
|
||||||
import imgui.type.ImInt;
|
import imgui.type.ImInt;
|
||||||
|
|
||||||
public class OptionsMenu extends BaseView {
|
public class OptionsMenu extends BaseView {
|
||||||
@@ -14,6 +17,30 @@ public class OptionsMenu extends BaseView {
|
|||||||
super(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
|
@Override
|
||||||
public void render() {
|
public void render() {
|
||||||
ImGui.text("Options");
|
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)) {
|
if (ImGui.sliderFloat("Vitesse d'animation de l'arrière plan", backgroundSpeed, 0.0f, 10.0f)) {
|
||||||
Options.BackgroundSpeed = backgroundSpeed[0];
|
Options.BackgroundSpeed = backgroundSpeed[0];
|
||||||
}
|
}
|
||||||
|
renderImageSelectButton();
|
||||||
renderReturnButton();
|
renderReturnButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user