From 05c2b496a25f6439d2bf669cdd37de2f941fc4c5 Mon Sep 17 00:00:00 2001 From: nawfe Date: Thu, 7 May 2020 19:49:38 +0200 Subject: [PATCH] Changement de langue --- src/ihm/controller/MenuController.java | 6 +++--- src/ihm/controller/MenuJoueurController.java | 2 +- src/ihm/controller/ParametreController.java | 9 ++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/ihm/controller/MenuController.java b/src/ihm/controller/MenuController.java index a76cd25..5e2685d 100644 --- a/src/ihm/controller/MenuController.java +++ b/src/ihm/controller/MenuController.java @@ -42,7 +42,7 @@ public class MenuController implements Initializable{ System.out.println("Passage à l'écran de choix des joueurs"); final URL fxmlURL = getClass().getResource("/ihm/ressources/Choix_joueur.fxml"); - final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE); + final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", ParametreController.LaLangue); final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle); AnchorPane pane = fxmlLoader.load(); Scene scene = new Scene(pane); @@ -60,7 +60,7 @@ public class MenuController implements Initializable{ System.out.println("Passage à l'écran des paramètres"); final URL fxmlURL = getClass().getResource("/ihm/ressources/parametre.fxml"); - final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE); + final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", ParametreController.LaLangue); final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle); Pane pane = fxmlLoader.load(); @@ -82,7 +82,7 @@ public class MenuController implements Initializable{ EffetSonore.playSoundEffect(fileSound1); System.out.println("Passage à l'écran des règles"); final URL fxmlURL = getClass().getResource("/ihm/ressources/Regles.fxml"); - final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE); + final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", ParametreController.LaLangue); final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle); AnchorPane pane = fxmlLoader.load(); Scene scene = new Scene(pane); diff --git a/src/ihm/controller/MenuJoueurController.java b/src/ihm/controller/MenuJoueurController.java index d8fd90d..9a6527a 100644 --- a/src/ihm/controller/MenuJoueurController.java +++ b/src/ihm/controller/MenuJoueurController.java @@ -26,7 +26,7 @@ public class MenuJoueurController implements Initializable{ public void changeZoneToScrollPaneJoueur(MouseEvent me) throws IOException { final URL fxmlURL = getClass().getResource("/ihm/ressources/ScrollPaneJoueur.fxml"); - final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.ENGLISH); + final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", ParametreController.LaLangue); final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle); AnchorPane bp = fxmlLoader.load(); ImageView iv = ((ImageView)me.getSource()); diff --git a/src/ihm/controller/ParametreController.java b/src/ihm/controller/ParametreController.java index 8f2bf6d..459e5a7 100644 --- a/src/ihm/controller/ParametreController.java +++ b/src/ihm/controller/ParametreController.java @@ -28,6 +28,7 @@ public class ParametreController implements Initializable { private CheckBox clair; @FXML private ComboBox langues; + public static Locale LaLangue = Locale.FRANCE; public static boolean cbMusiqueCoche = false; // verifi si la checbox musical est coche public static boolean cbSonCoche = false; public static boolean cbClair = false; @@ -63,6 +64,12 @@ public class ParametreController implements Initializable { InputStream fileSound1 = getClass().getResourceAsStream("/ihm/ressources/musique/BEEP1.wav"); + if(langues.getValue()=="Anglais") { + LaLangue=Locale.ENGLISH; + } + else if(langues.getValue()=="Français") { + LaLangue=Locale.FRANCE; + } //Pour la musique if (fileMusique!=null) { @@ -138,7 +145,7 @@ public class ParametreController implements Initializable { // Quitter les paramètres final URL fxmlURL = getClass().getResource("/ihm/ressources/Menu.fxml"); - final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE); + final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", ParametreController.LaLangue); final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle); Pane pane = fxmlLoader.load();