From ff4f0aaab1ea20b52092eeecc120719a1b3f644d Mon Sep 17 00:00:00 2001 From: Yessine Ben El Bey Date: Thu, 7 May 2020 17:11:08 +0200 Subject: [PATCH 01/90] Responsive --- src/ihm/Main.java | 9 ++++++++- src/ihm/controller/ParametreController.java | 9 +++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/ihm/Main.java b/src/ihm/Main.java index 6f9f30e..8d61526 100644 --- a/src/ihm/Main.java +++ b/src/ihm/Main.java @@ -1,5 +1,7 @@ package ihm; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; import java.net.URL; import java.util.Locale; import java.util.ResourceBundle; @@ -14,6 +16,10 @@ import javafx.stage.WindowEvent; import main.GestionnaireJeu; public class Main extends Application { + GraphicsDevice Gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); + int width = Gd.getDisplayMode().getWidth(); + int height = Gd.getDisplayMode().getHeight(); + @Override public void start(Stage primaryStage) throws Exception { final URL fxmlURL = getClass().getResource("ressources/Menu.fxml"); @@ -22,7 +28,8 @@ public class Main extends Application { Pane root = fxmlLoader.load(); primaryStage.setTitle("Shadow Hunters"); - primaryStage.setScene(new Scene(root)); + primaryStage.setScene(new Scene(root,width,height)); + primaryStage.setMaximized(true); primaryStage.centerOnScreen(); primaryStage.setOnCloseRequest(new EventHandler() { @Override diff --git a/src/ihm/controller/ParametreController.java b/src/ihm/controller/ParametreController.java index 8f2bf6d..db625ab 100644 --- a/src/ihm/controller/ParametreController.java +++ b/src/ihm/controller/ParametreController.java @@ -107,12 +107,13 @@ public class ParametreController implements Initializable { // Pour la couleur du theme - /* + if (clair.isSelected()) { - //Pane root = FXMLLoader.load(getClass().getResource("../ressources/parametre.fxml")); - //root.setStyle("ressources/style/menuLight.css"); + //Pane root = FXMLLoader.load(getClass().getResource("../ressources/menu.fxml")); + //rootPane.setStyle("-fx-background-color: white;"); + } - if (liste != null) { + /*if (liste != null) { for (int i = 0; i < liste.length; i++) { System.out.println(liste[i]); From ffa5398c4f13921a8c83fb52f55344373da5dcdc Mon Sep 17 00:00:00 2001 From: Bastien NOEL Date: Thu, 7 May 2020 17:19:46 +0200 Subject: [PATCH 02/90] ajout slider parametre pour la musique --- src/ihm/Musique.java | 11 ++++++++- src/ihm/controller/ParametreController.java | 25 +++++++++++++++++---- src/ihm/controller/PauseController.java | 2 ++ src/ihm/ressources/parametre.fxml | 21 +++-------------- 4 files changed, 36 insertions(+), 23 deletions(-) diff --git a/src/ihm/Musique.java b/src/ihm/Musique.java index 89880e5..2490cd6 100644 --- a/src/ihm/Musique.java +++ b/src/ihm/Musique.java @@ -14,7 +14,7 @@ public class Musique { public static long clipTimePosition = 0; public static boolean musiqueEnCours = false; - static FloatControl volume ; + public static FloatControl volume ; public static void playMusique(InputStream path) { @@ -61,5 +61,14 @@ public class Musique { public static void volumeDown(Float valeur) { volume.setValue(volume.getValue() -valeur); } + + public static void setVolume(Float fValeur) { + volume.setValue(fValeur); + } + + public static void setVolume(double dValeur) { + float decibel = (float) (Math.log(dValeur) / Math.log(10) * 20); + volume.setValue(decibel); + } } diff --git a/src/ihm/controller/ParametreController.java b/src/ihm/controller/ParametreController.java index db625ab..9bf4755 100644 --- a/src/ihm/controller/ParametreController.java +++ b/src/ihm/controller/ParametreController.java @@ -14,6 +14,7 @@ import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; import javafx.scene.control.CheckBox; import javafx.scene.control.ComboBox; +import javafx.scene.control.Slider; import javafx.scene.input.MouseEvent; import javafx.scene.layout.Pane; @@ -28,9 +29,13 @@ public class ParametreController implements Initializable { private CheckBox clair; @FXML private ComboBox langues; + @FXML + private Slider sliderMusique; + public static boolean cbMusiqueCoche = false; // verifi si la checbox musical est coche public static boolean cbSonCoche = false; public static boolean cbClair = false; + public static double slideValue; boolean MusiqueLancee = false; //verifi si la musique a déja été lancé une première fois @@ -45,10 +50,10 @@ public class ParametreController implements Initializable { @Override public void initialize(URL arg0, ResourceBundle arg1) { - cmusique.setSelected(cbMusiqueCoche); - cbEffetSonore.setSelected(cbSonCoche); - clair.setSelected(cbClair); - + cmusique.setSelected(cbMusiqueCoche); + cbEffetSonore.setSelected(cbSonCoche); + clair.setSelected(cbClair); + sliderMusique.setValue(slideValue); langues.getItems().add("Anglais"); @@ -75,6 +80,7 @@ public class ParametreController implements Initializable { } else if (Musique.musiqueEnCours != true) { Musique.resumeMusique(Musique.clip); // si elle a deja été lancé mais mis en pause, reprend a partir du point d'arret + Musique.musiqueEnCours = true; } } else { @@ -161,5 +167,16 @@ public class ParametreController implements Initializable { Musique.volumeDown(5.f); System.out.println("on baisse le son"); } + + @FXML + public void slideVolumeMusique(MouseEvent mouseEvent) throws IOException{ + + if(Musique.musiqueEnCours == true) { + Musique.setVolume(sliderMusique.getValue()); + slideValue = sliderMusique.getValue(); + + } + + } } diff --git a/src/ihm/controller/PauseController.java b/src/ihm/controller/PauseController.java index 51cb9c4..6e1435e 100644 --- a/src/ihm/controller/PauseController.java +++ b/src/ihm/controller/PauseController.java @@ -70,6 +70,8 @@ public class PauseController implements Initializable { System.out.println("fichier audio non trouvé"); } + + // Pour les effets sonores if (cbEffet.isSelected() == true) { System.out.println("\tEffets sonores activé"); diff --git a/src/ihm/ressources/parametre.fxml b/src/ihm/ressources/parametre.fxml index ff6bd51..7a0f892 100644 --- a/src/ihm/ressources/parametre.fxml +++ b/src/ihm/ressources/parametre.fxml @@ -5,12 +5,13 @@ + - + @@ -18,23 +19,7 @@ - - - - - - + From 78f251d5f184dc6106ab2834c4b5892b9f43fe01 Mon Sep 17 00:00:00 2001 From: Bastien NOEL Date: Thu, 7 May 2020 18:01:04 +0200 Subject: [PATCH 03/90] ajout du slider dans le menu pause pour la musique --- src/ihm/controller/ParametreController.java | 20 ++++--- src/ihm/controller/PauseController.java | 58 +++++++++++++-------- src/ihm/ressources/Pause.fxml | 23 ++------ 3 files changed, 52 insertions(+), 49 deletions(-) diff --git a/src/ihm/controller/ParametreController.java b/src/ihm/controller/ParametreController.java index 9bf4755..e2cff73 100644 --- a/src/ihm/controller/ParametreController.java +++ b/src/ihm/controller/ParametreController.java @@ -156,6 +156,16 @@ public class ParametreController implements Initializable { } + @FXML + public void slideVolumeMusique(MouseEvent mouseEvent) throws IOException{ + + if(Musique.musiqueEnCours == true) { + Musique.setVolume(sliderMusique.getValue()); + slideValue = sliderMusique.getValue(); + + } + /* + @FXML public void monterVolume(MouseEvent mouseEvent) throws IOException{ Musique.volumeUp(5.f); @@ -167,15 +177,9 @@ public class ParametreController implements Initializable { Musique.volumeDown(5.f); System.out.println("on baisse le son"); } + */ - @FXML - public void slideVolumeMusique(MouseEvent mouseEvent) throws IOException{ - - if(Musique.musiqueEnCours == true) { - Musique.setVolume(sliderMusique.getValue()); - slideValue = sliderMusique.getValue(); - - } + } diff --git a/src/ihm/controller/PauseController.java b/src/ihm/controller/PauseController.java index 6e1435e..6d7fc2a 100644 --- a/src/ihm/controller/PauseController.java +++ b/src/ihm/controller/PauseController.java @@ -4,7 +4,6 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.Locale; -import java.util.Map; import java.util.ResourceBundle; import ihm.EffetSonore; @@ -13,33 +12,34 @@ import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; import javafx.scene.Node; -import javafx.scene.Scene; import javafx.scene.control.CheckBox; +import javafx.scene.control.Slider; import javafx.scene.input.MouseEvent; import javafx.scene.layout.AnchorPane; import javafx.stage.Stage; import main.GestionnaireJeu; -import main.Joueur; public class PauseController implements Initializable { @FXML private CheckBox cbMusique; @FXML private CheckBox cbEffet; + @FXML + private Slider sliderMusiquePause; String filepathMusique = "src//ihm//ressources//musique//The_Red_Fox_Tavern.wav"; InputStream fileMusique = getClass().getResourceAsStream("/ihm/ressources/musique/The_Red_Fox_Tavern.wav"); boolean MusiqueLancee = ParametreController.cbMusiqueCoche; boolean SonLance = ParametreController.cbSonCoche; + public static double slideValuePause; @Override public void initialize(URL arg0, ResourceBundle arg1) { cbMusique.setSelected(ParametreController.cbMusiqueCoche); cbEffet.setSelected(ParametreController.cbSonCoche); - - + sliderMusiquePause.setValue(ParametreController.slideValue); } @FXML @@ -56,11 +56,12 @@ public class PauseController implements Initializable { Musique.playMusique(fileMusique); Musique.musiqueEnCours = true; MusiqueLancee = true; - } else if (MusiqueLancee ==false && Musique.musiqueEnCours != true) { + } else if (MusiqueLancee == false && Musique.musiqueEnCours != true) { Musique.resumeMusique(Musique.clip); // si elle a deja été lancé mais mis en pause, reprend a partir du point d'arret + Musique.musiqueEnCours = true; } - - } else if (MusiqueLancee == true){ + + } else if (MusiqueLancee == true) { Musique.pauseMusique(Musique.clip); // met en pause la musique Musique.musiqueEnCours = false; MusiqueLancee = false; @@ -70,8 +71,6 @@ public class PauseController implements Initializable { System.out.println("fichier audio non trouvé"); } - - // Pour les effets sonores if (cbEffet.isSelected() == true) { System.out.println("\tEffets sonores activé"); @@ -84,6 +83,7 @@ public class PauseController implements Initializable { ParametreController.cbSonCoche = cbEffet.isSelected(); ParametreController.cbMusiqueCoche = cbMusique.isSelected(); + ParametreController.slideValue = slideValuePause; EffetSonore.playSoundEffect(fileSound1); // met un bruit sur le bouton si les effets sonores sont activés @@ -101,14 +101,13 @@ public class PauseController implements Initializable { Stage appStage = (Stage) ((Node) me.getSource()).getScene().getWindow(); appStage.close(); -/* final URL fxmlURL = getClass().getResource("/ihm/ressources/Menu.fxml"); - final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRENCH); - final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle); - AnchorPane root = fxmlLoader.load(); */ - - - - + /* + * final URL fxmlURL = getClass().getResource("/ihm/ressources/Menu.fxml"); + * final ResourceBundle bundle = + * ResourceBundle.getBundle("domaine.properties.langue", Locale.FRENCH); final + * FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle); AnchorPane root = + * fxmlLoader.load(); + */ final URL fxmlURL = getClass().getResource("/ihm/ressources/Menu.fxml"); final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRENCH); @@ -118,15 +117,32 @@ public class PauseController implements Initializable { } @FXML - public void monterVolume(MouseEvent mouseEvent) throws IOException{ + public void slideVolumeMusique(MouseEvent mouseEvent) throws IOException { + + if (Musique.musiqueEnCours == true) { + System.out.println("slide"); + Musique.setVolume(sliderMusiquePause.getValue()); + slideValuePause = sliderMusiquePause.getValue(); + + }else { + System.out.println("probleme"); + } + } + + /* + @FXML + public void monterVolume(MouseEvent mouseEvent) throws IOException { Musique.volumeUp(5.f); System.out.println("on monte le son"); } - + @FXML - public void baisserVolume(MouseEvent mouseEvent) throws IOException{ + public void baisserVolume(MouseEvent mouseEvent) throws IOException { Musique.volumeDown(5.f); System.out.println("on baisse le son"); } + */ + + } diff --git a/src/ihm/ressources/Pause.fxml b/src/ihm/ressources/Pause.fxml index b925919..656c8af 100644 --- a/src/ihm/ressources/Pause.fxml +++ b/src/ihm/ressources/Pause.fxml @@ -4,6 +4,7 @@ + @@ -45,28 +46,10 @@ - + - - + - - - From a6a8b326d9cfd8e2397f94d50448aa232995c3a4 Mon Sep 17 00:00:00 2001 From: Yessine Ben El Bey Date: Thu, 7 May 2020 18:08:54 +0200 Subject: [PATCH 04/90] Parametre --- src/ihm/controller/ParametreController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ihm/controller/ParametreController.java b/src/ihm/controller/ParametreController.java index db625ab..27bc05a 100644 --- a/src/ihm/controller/ParametreController.java +++ b/src/ihm/controller/ParametreController.java @@ -62,7 +62,6 @@ public class ParametreController implements Initializable { public void enregistre(MouseEvent mouseEvent) throws IOException, Exception { InputStream fileSound1 = getClass().getResourceAsStream("/ihm/ressources/musique/BEEP1.wav"); - //Pour la musique if (fileMusique!=null) { @@ -110,7 +109,8 @@ public class ParametreController implements Initializable { if (clair.isSelected()) { //Pane root = FXMLLoader.load(getClass().getResource("../ressources/menu.fxml")); - //rootPane.setStyle("-fx-background-color: white;"); + rootPane.setStyle("-fx-background-color: white;"); + rootPane.applyCss(); } /*if (liste != null) { From 5e1ee06436e415b9ad6603b076f0261dff73bb0a Mon Sep 17 00:00:00 2001 From: Yessine-iut Date: Fri, 8 May 2020 14:10:12 +0200 Subject: [PATCH 05/90] Suppression responsive --- src/ihm/Main.java | 6 +++--- src/ihm/controller/ParametreController.java | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ihm/Main.java b/src/ihm/Main.java index 48fd41b..254d7de 100644 --- a/src/ihm/Main.java +++ b/src/ihm/Main.java @@ -16,9 +16,9 @@ import javafx.stage.WindowEvent; import main.GestionnaireJeu; public class Main extends Application { - GraphicsDevice Gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); + /*GraphicsDevice Gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); int width = Gd.getDisplayMode().getWidth(); - int height = Gd.getDisplayMode().getHeight(); + int height = Gd.getDisplayMode().getHeight(); */ @Override public void start(Stage primaryStage) throws Exception { @@ -28,7 +28,7 @@ public class Main extends Application { Pane root = fxmlLoader.load(); primaryStage.setTitle("Shadow Hunters"); - primaryStage.setScene(new Scene(root,width,height)); + primaryStage.setScene(new Scene(root)); primaryStage.setMaximized(true); primaryStage.centerOnScreen(); primaryStage.setOnCloseRequest(new EventHandler() { diff --git a/src/ihm/controller/ParametreController.java b/src/ihm/controller/ParametreController.java index 8a99886..52ac4ab 100644 --- a/src/ihm/controller/ParametreController.java +++ b/src/ihm/controller/ParametreController.java @@ -32,10 +32,13 @@ public class ParametreController implements Initializable { @FXML private Slider sliderMusique; + + public static boolean cbMusiqueCoche = false; // verifi si la checbox musical est coche public static boolean cbSonCoche = false; public static boolean cbClair = false; public static double slideValue; + public static String langueChoisi; boolean MusiqueLancee = false; //verifi si la musique a déja été lancé une première fois @@ -115,10 +118,12 @@ public class ParametreController implements Initializable { if (clair.isSelected()) { //Pane root = FXMLLoader.load(getClass().getResource("../ressources/menu.fxml")); + rootPane.setStyle("-fx-background-color: white;"); rootPane.applyCss(); } - + rootPane.setStyle("-fx-background-color: white;"); + rootPane.applyCss(); /*if (liste != null) { for (int i = 0; i < liste.length; i++) { @@ -143,6 +148,7 @@ public class ParametreController implements Initializable { EffetSonore.playSoundEffect(fileSound1); //emet un bruit sur le bouton si les effets sonores sont activés + // Quitter les paramètres final URL fxmlURL = getClass().getResource("/ihm/ressources/Menu.fxml"); final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE); From d6fe0f0d80ac8cbefe716f68d8a95326528d1ee3 Mon Sep 17 00:00:00 2001 From: Paul Gross Date: Fri, 8 May 2020 16:08:56 +0200 Subject: [PATCH 06/90] Ajout des cartes lieux en provenance de la bdd --- src/carte/CarteLieuMultiple.java | 2 + src/carte/CarteLieuType.java | 1 + src/carte/CartePiochable.java | 2 + src/database/CreatingCardsTest.java | 4 +- src/database/QueryGenerator.java | 2 + src/database/RessourceLoader.java | 46 ++++++--- src/ihm/Main.java | 5 +- src/ihm/controller/GestionnaireDePions.java | 8 +- src/ihm/controller/PlateauController.java | 65 +++++++++++- src/ihm/ressources/PlateauTest2.fxml | 106 +++++++++++++------- src/ihm/ressources/style/plateau.css | 5 + src/main/GestionnaireJeu.java | 16 ++- src/main/Joueur.java | 4 +- src/main/Pioche.java | 6 ++ src/main/Plateau.java | 12 ++- 15 files changed, 212 insertions(+), 72 deletions(-) diff --git a/src/carte/CarteLieuMultiple.java b/src/carte/CarteLieuMultiple.java index 1c43f93..cb35003 100644 --- a/src/carte/CarteLieuMultiple.java +++ b/src/carte/CarteLieuMultiple.java @@ -25,6 +25,8 @@ public class CarteLieuMultiple extends CarteLieu{ */ public void utiliser(Joueur j) { Pioche p = (Pioche) j.choisir(pioches); + System.out.println(pioches+ " "+p); + System.out.println(p.getStack()); Carte c = p.piocher(); c.utiliser(j); } diff --git a/src/carte/CarteLieuType.java b/src/carte/CarteLieuType.java index 8982607..e0af7e0 100644 --- a/src/carte/CarteLieuType.java +++ b/src/carte/CarteLieuType.java @@ -31,6 +31,7 @@ public class CarteLieuType extends CarteLieu{ * @param j Appel la méthode utiliser de effet sur le joueur j */ public void utiliser(Joueur j) { + System.out.println(pioche); CartePiochable carte = pioche.piocher(); carte.utiliser(j); } diff --git a/src/carte/CartePiochable.java b/src/carte/CartePiochable.java index 10890e7..b5ff603 100644 --- a/src/carte/CartePiochable.java +++ b/src/carte/CartePiochable.java @@ -20,10 +20,12 @@ public class CartePiochable extends CarteCondition implements Serializable{ public CartePiochable(Type t, String nom, String description) { super(nom, description); + this.type = t; } public CartePiochable(Type t, Effet e, Condition c) { super(); + this.type = t; this.setEffet(e); this.setCondition(c); } diff --git a/src/database/CreatingCardsTest.java b/src/database/CreatingCardsTest.java index db5e5ef..cb4aa81 100644 --- a/src/database/CreatingCardsTest.java +++ b/src/database/CreatingCardsTest.java @@ -45,7 +45,7 @@ public class CreatingCardsTest { //Ange gardien try { - /* + DatabaseManager.queryInsertObject(2,new CartePiochable(CartePiochable.Type.LUMIERE, new EffetSelf(new ActionAltererStatistiquesJoueur(Joueur.PLAYER_IMMUNITY, 1, true)))); @@ -240,7 +240,7 @@ public class CreatingCardsTest { DatabaseManager.queryInsertObject(56,new Metamorphe()); DatabaseManager.queryInsertObject(57,new Vampire()); - */ + //62 diff --git a/src/database/QueryGenerator.java b/src/database/QueryGenerator.java index 7147a91..fb27905 100644 --- a/src/database/QueryGenerator.java +++ b/src/database/QueryGenerator.java @@ -54,6 +54,8 @@ public class QueryGenerator { table = getTable("CartesPersonnage"); } else if(id <= 61) { table = getTable("CartesDos"); + }else if(id <= 67) { + table = getTable("CartesLieu"); } return "SELECT * FROM " + table + " WHERE id = " + id; } diff --git a/src/database/RessourceLoader.java b/src/database/RessourceLoader.java index a5e9154..b7eb816 100644 --- a/src/database/RessourceLoader.java +++ b/src/database/RessourceLoader.java @@ -1,6 +1,7 @@ package database; -import java.awt.Image; + +import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; @@ -15,6 +16,8 @@ import javax.imageio.ImageIO; import carte.Carte; import carte.CarteLieu; import carte.CartePiochable; +import javafx.embed.swing.SwingFXUtils; +import javafx.scene.image.Image; import personnage.CartePersonnage; public class RessourceLoader { @@ -35,28 +38,30 @@ public class RessourceLoader { private final int ID_DOS_TENEBRE= 59; private final int ID_DOS_VISION= 61; - private Map ressourcesCartes; - private Map ressourcesDosCartes; + private Map ressourcesCartes; + private Map ressourcesDosCartes; public RessourceLoader() { - this.ressourcesCartes = new HashMap(); - this.ressourcesDosCartes = new HashMap(); + this.ressourcesCartes = new HashMap(); + this.ressourcesDosCartes = new HashMap(); } private Map loadCards() throws ClassNotFoundException, IOException{ Table t = new Table(); Map cartes = new HashMap(); - for(int i = 0; i < 61; i++) { + for(int i = 0; i < 67; i++) { String query = QueryGenerator.selectId(i+1); t.remplirTableQuery(query); - byte[] obj = t.getList().get(i).getObjet(); + Record r = t.getList().get(i); + byte[] obj = r.getObjet(); if(obj != null) { Object o = deserialize(obj); Carte c = (Carte)o; + c.setNom(r.getNom()); cartes.put(i+1, c); } } @@ -105,21 +110,21 @@ public class RessourceLoader { return is.readObject(); } - private Image loadImage(int id) throws IOException { + private BufferedImage loadImage(int id) throws IOException { String name = ""+id+".png"; String url = "ressources/cartes/"+name; - Image picture = ImageIO.read(new File(url)); + BufferedImage picture = ImageIO.read(new File(url)); return picture; } - private Map getMapImageCarte(Map cartes) throws IOException{ + private Map getMapImageCarte(Map cartes) throws IOException{ - Map mapCarteImage = new HashMap(); + Map mapCarteImage = new HashMap(); for(Integer i : cartes.keySet()) { Carte c = cartes.get(i); - Image img = loadImage(i); + BufferedImage img = loadImage(i); mapCarteImage.put(c,img); } @@ -164,13 +169,12 @@ public class RessourceLoader { List cartesType = new ArrayList(); for(Carte c : cartes) { - - if(c instanceof CartePiochable) { CartePiochable carte = (CartePiochable) c; - + System.out.println(carte.getNom()+" "+carte.getType()); CartePiochable.Type type = carte.getType(); + if(t == type) { cartesType.add(carte); } @@ -208,4 +212,16 @@ public class RessourceLoader { return cartesLieu; } + public Map getRessourceCartes(){ + return this.ressourcesCartes; + } + + public Map getRessourceDosCartes(){ + return this.ressourcesDosCartes; + } + + public static Image toJavaFX(BufferedImage img) { + Image image = SwingFXUtils.toFXImage(img, null); + return image; + } } diff --git a/src/ihm/Main.java b/src/ihm/Main.java index 48fd41b..693c2e4 100644 --- a/src/ihm/Main.java +++ b/src/ihm/Main.java @@ -6,6 +6,7 @@ import java.net.URL; import java.util.Locale; import java.util.ResourceBundle; +import database.RessourceLoader; import javafx.application.Application; import javafx.event.EventHandler; import javafx.fxml.FXMLLoader; @@ -44,11 +45,11 @@ public class Main extends Application { public static void main(String[] args) { GestionnaireJeu gj = GestionnaireJeu.getGestionnaireJeu(); - /* + RessourceLoader rl = new RessourceLoader(); rl.loadRessources(); gj.setRessourceLoader(rl); - */ + launch(args); } } \ No newline at end of file diff --git a/src/ihm/controller/GestionnaireDePions.java b/src/ihm/controller/GestionnaireDePions.java index dd44d71..6f57989 100644 --- a/src/ihm/controller/GestionnaireDePions.java +++ b/src/ihm/controller/GestionnaireDePions.java @@ -44,8 +44,7 @@ public class GestionnaireDePions { StackPane nNew = (StackPane) gp.getChildren().get(damage); FlowPane fpNew = (FlowPane) nNew.getChildren().get(0); - fpNew.getChildren().add(pionVie); - + if(!fpNew.getChildren().contains(pionVie)) fpNew.getChildren().add(pionVie); } @@ -66,9 +65,10 @@ public class GestionnaireDePions { } StackPane sp = (StackPane) hbox.getChildren().get(indexCL%2); - FlowPane fp = (FlowPane) sp.getChildren().get(0); + FlowPane fp = (FlowPane) sp.getChildren().get(1); - fp.getChildren().add(this.pionLieu); + if(!fp.getChildren().contains(this.pionLieu)) fp.getChildren().add(this.pionLieu); + } diff --git a/src/ihm/controller/PlateauController.java b/src/ihm/controller/PlateauController.java index 4b9e416..00e944c 100644 --- a/src/ihm/controller/PlateauController.java +++ b/src/ihm/controller/PlateauController.java @@ -1,6 +1,7 @@ package ihm.controller; +import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; import java.net.URL; @@ -11,20 +12,31 @@ import java.util.Map; import java.util.ResourceBundle; import java.util.Set; +import carte.Carte; +import carte.CarteLieu; +import database.RessourceLoader; import ihm.EffetSonore; import ihm.PopUp; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; import javafx.scene.Group; -import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.control.Label; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; import javafx.scene.input.MouseEvent; import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.Background; +import javafx.scene.layout.BackgroundImage; +import javafx.scene.layout.BackgroundPosition; +import javafx.scene.layout.BackgroundRepeat; +import javafx.scene.layout.BackgroundSize; +import javafx.scene.layout.FlowPane; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; +import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import main.GestionnaireJeu; @@ -41,7 +53,9 @@ public class PlateauController implements Initializable { private ChoisirBoolean cb; - + + + private Map mapRessourcesCartes; public static int DICE_SIX = 2; public static int DICE_QUATRE = 1; public static int DICE_BOTH = 0; @@ -55,6 +69,8 @@ public class PlateauController implements Initializable { this.joueursIHM = new ArrayList(); GestionnaireJeu gj = GestionnaireJeu.getGestionnaireJeu(); + RessourceLoader rl = gj.getRessourceLoader(); + Map map = gj.getMapJoueurs(); for(int i = 0 ; i < gridPaneVie.getChildren().size();i++) { @@ -75,7 +91,12 @@ public class PlateauController implements Initializable { } + mapRessourcesCartes = rl.getRessourceCartes(); + + List cl = gj.getCartesLieux(); + List ivs = this.getLieux(); + applyImages(cl,ivs); // BUTTONS ETC //System.out.println(this.joueursPane); @@ -162,6 +183,31 @@ public class PlateauController implements Initializable { } + private void applyImages(List cls, List ivs) { + + int size = cls.size(); + if(cls.size() == ivs.size()) { + + for(int i = 0; i < size; i++) { + + CarteLieu cl = cls.get(i); + ImageView iv = ivs.get(i); + + BufferedImage bi = mapRessourcesCartes.get(cl); + Image image = RessourceLoader.toJavaFX(bi); + applyImageLieu(iv,image); + } + } + } + + private void applyImageLieu(ImageView iv, Image im) { + + StackPane sp = (StackPane) iv.getParent(); + iv.setImage(im); + iv.fitHeightProperty().bind(sp.heightProperty()); + } + + private Pane getPaneJoueur(int i) { System.out.println("i "+i); @@ -197,6 +243,21 @@ public class PlateauController implements Initializable { return (Pane) gp.getChildren().get(i%2); } + private List getLieux() { + + List views = new ArrayList(); + for(int i = 0 ; i < gridPaneLieux.getChildren().size(); i++) { + + HBox p = (HBox) gridPaneLieux.getChildren().get(i); + for(int j = 0; j < p.getChildren().size(); j++) { + StackPane sp = (StackPane) p.getChildren().get(j); + ImageView iv = (ImageView) sp.getChildren().get(0); + views.add(iv); + } + } + return views; + } + /** * Affiche aux yeux de tous la carte personnage du joueur * diff --git a/src/ihm/ressources/PlateauTest2.fxml b/src/ihm/ressources/PlateauTest2.fxml index 8c4f657..b58ca3c 100644 --- a/src/ihm/ressources/PlateauTest2.fxml +++ b/src/ihm/ressources/PlateauTest2.fxml @@ -18,7 +18,7 @@ - + @@ -70,6 +70,9 @@ + + + @@ -108,6 +111,9 @@ + + + @@ -167,6 +173,9 @@ + + + @@ -205,17 +214,20 @@ - + - + @@ -249,19 +261,19 @@ - + - - - + + + - + - + @@ -278,67 +290,79 @@ - - - + + + - + - + - + - - + + - + - - + + + + + + + + - + - + - - + + - + - - + + + + + - + - + - - + + - + - - + + + + + - + @@ -633,6 +657,9 @@ + + + @@ -671,6 +698,9 @@ + + + @@ -727,6 +757,9 @@ - + @@ -64,6 +64,11 @@ + + + + +