Ajout des cartes équipement
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
package ihm;
|
||||
|
||||
import carte.CarteEquipement;
|
||||
import ihm.controller.PlateauController;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
|
||||
public class ImageViewEquipement extends ImageView{
|
||||
@ -9,6 +11,8 @@ public class ImageViewEquipement extends ImageView{
|
||||
|
||||
public ImageViewEquipement(CarteEquipement ce) {
|
||||
this.ce = ce;
|
||||
Image im = PlateauController.getImageCarte(ce);
|
||||
this.setImage(im);
|
||||
}
|
||||
|
||||
public CarteEquipement getCp() {
|
||||
|
@ -8,29 +8,21 @@ import java.util.ResourceBundle;
|
||||
import carte.CarteEquipement;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import main.GestionnaireJeu;
|
||||
|
||||
public class ChoisirEquipement implements Initializable{
|
||||
@FXML private GridPane grilleEquipement;
|
||||
@FXML private HBox hbox;
|
||||
|
||||
private List<CarteEquipement> equipements = new ArrayList<CarteEquipement>();
|
||||
private CarteEquipement equipementSelected;
|
||||
|
||||
@Override
|
||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||
for (int i=0; i<equipements.size(); i++) {
|
||||
ImageView carte = (ImageView) grilleEquipement.getChildren().get(i);
|
||||
|
||||
/*InputStream input = getClass().getResourceAsStream("/ihm/ressources/img/" + "nomcarte" + ".png");
|
||||
Image image = new Image(input);
|
||||
carte.setImage(image);*/
|
||||
|
||||
int numEquipement = i;
|
||||
carte.setOnMouseClicked(e -> {
|
||||
equipementSelected = equipements.get(numEquipement);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public List<CarteEquipement> getEquipements() {
|
||||
@ -61,4 +53,24 @@ public class ChoisirEquipement implements Initializable{
|
||||
return equipementSelected;
|
||||
}
|
||||
|
||||
public void setListCarteEquipements(List<CarteEquipement> lce) {
|
||||
this.equipements = lce;
|
||||
}
|
||||
|
||||
public void initChoisirEquipement() {
|
||||
for (CarteEquipement ce : equipements) {
|
||||
|
||||
ImageView iv = new ImageView(PlateauController.getImageCarte(ce));
|
||||
|
||||
hbox.getChildren().add(iv);
|
||||
|
||||
iv.fitHeightProperty().bind(hbox.heightProperty());
|
||||
//iv.fitWidthProperty().bind(scrollpane.widthProperty());
|
||||
iv.setPreserveRatio(true);
|
||||
iv.setOnMouseClicked(e -> {
|
||||
equipementSelected = ce;
|
||||
GestionnaireJeu.notifyPlateau();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
package ihm.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import carte.CarteEquipement;
|
||||
import database.RessourceLoader;
|
||||
import ihm.ImageViewEquipement;
|
||||
@ -226,22 +230,28 @@ public class JoueurIHM {
|
||||
public void ajouterEquipement(CarteEquipement e) {
|
||||
HBox hb = getPaneEquipement();
|
||||
ImageViewEquipement ive = new ImageViewEquipement(e);
|
||||
hb.getChildren().add(new ImageViewEquipement(e));
|
||||
hb.getChildren().add(ive);
|
||||
ive.setPreserveRatio(true);
|
||||
ive.fitHeightProperty().bind(hb.heightProperty());
|
||||
|
||||
//ive.fitWidthProperty().bind(hb.widthProperty());
|
||||
}
|
||||
|
||||
public void retirerEquipement(CarteEquipement e) {
|
||||
|
||||
HBox hb = getPaneEquipement();
|
||||
for (Node n : hb.getChildren()) {
|
||||
if (n instanceof ImageViewEquipement) {
|
||||
ImageViewEquipement ive = (ImageViewEquipement) n;
|
||||
if (ive.contains(e)) {
|
||||
hb.getChildren().remove(ive);
|
||||
List<ImageView> liv = new ArrayList<ImageView>();
|
||||
for(Iterator<Node> iterator = hb.getChildren().iterator(); iterator.hasNext();) {
|
||||
Node n = iterator.next();
|
||||
|
||||
if (n instanceof ImageViewEquipement) {
|
||||
ImageViewEquipement ive = (ImageViewEquipement) n;
|
||||
if (ive.contains(e)) {
|
||||
liv.add(ive);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
hb.getChildren().removeAll(liv);
|
||||
}
|
||||
|
||||
public String getNom() {
|
||||
|
@ -58,8 +58,8 @@ public class PlateauController implements Initializable {
|
||||
private PiocherCarte pc;
|
||||
private LancerDes ld;
|
||||
|
||||
private Map<Carte,BufferedImage> mapRessourcesCartes;
|
||||
private Map<String,BufferedImage> mapRessourcesDosCartes;
|
||||
private static Map<Carte,BufferedImage> mapRessourcesCartes;
|
||||
private static Map<String,BufferedImage> mapRessourcesDosCartes;
|
||||
|
||||
public static int DICE_SIX = 1;
|
||||
public static int DICE_QUATRE = 0;
|
||||
@ -347,12 +347,14 @@ public class PlateauController implements Initializable {
|
||||
}
|
||||
|
||||
|
||||
public void afficherChoisirEquipementVole(Joueur j) throws IOException {
|
||||
public void afficherChoisirEquipementVole(Joueur j, List<CarteEquipement> lce) throws IOException {
|
||||
final URL fxmlURL = getClass().getResource("/ihm/ressources/Jouer_tour(2a)voler_equipement.fxml");
|
||||
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE);
|
||||
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle);
|
||||
Pane root = (Pane)fxmlLoader.load();
|
||||
this.ce = fxmlLoader.getController();
|
||||
this.ce.setListCarteEquipements(lce);
|
||||
this.ce.initChoisirEquipement();
|
||||
JoueurIHM jihm = getJoueurIHM(j);
|
||||
jihm.setZoneJoueur(root);
|
||||
}
|
||||
@ -369,7 +371,7 @@ public class PlateauController implements Initializable {
|
||||
|
||||
JoueurIHM jihm = getJoueurIHM(j);
|
||||
Pane p = (Pane) jihm.getZoneJoueur();
|
||||
Pane pane = null;
|
||||
Pane pane = new Pane();
|
||||
|
||||
if(p.getChildren() != null && p.getChildren().size() > 0) {
|
||||
|
||||
@ -481,13 +483,13 @@ public class PlateauController implements Initializable {
|
||||
}
|
||||
|
||||
|
||||
public Image getImageCarte(Carte carte) {
|
||||
BufferedImage bi = this.mapRessourcesCartes.get(carte);
|
||||
public static Image getImageCarte(Carte carte) {
|
||||
BufferedImage bi = mapRessourcesCartes.get(carte);
|
||||
return RessourceLoader.toJavaFX(bi);
|
||||
}
|
||||
|
||||
public Image getImageDosCarte(String s) {
|
||||
BufferedImage bi = this.mapRessourcesDosCartes.get(s);
|
||||
public static Image getImageDosCarte(String s) {
|
||||
BufferedImage bi = mapRessourcesDosCartes.get(s);
|
||||
return RessourceLoader.toJavaFX(bi);
|
||||
}
|
||||
|
||||
@ -501,7 +503,6 @@ public class PlateauController implements Initializable {
|
||||
public void retirerEquipement(Joueur j, CarteEquipement e) {
|
||||
JoueurIHM jihm = getJoueurIHM(j);
|
||||
jihm.retirerEquipement(e);
|
||||
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
|
@ -1,27 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="210.0" prefWidth="260.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ihm.controller.ChoisirEquipement">
|
||||
<AnchorPane stylesheets="@style/plateau.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ihm.controller.ChoisirEquipement">
|
||||
<children>
|
||||
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" stylesheets="@style/popUp.css" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<VBox alignment="CENTER" spacing="10.0" styleClass="background" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<Label layoutX="58.0" layoutY="14.0" text="%voler.equipement.joueur" />
|
||||
<ScrollPane layoutX="28.0" layoutY="38.0">
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" styleClass="text" text="%voler.equipement.joueur" />
|
||||
<ScrollPane fx:id="scrollpane" fitToHeight="true" fitToWidth="true" prefHeight="144.0" prefWidth="144.0" vbarPolicy="NEVER" VBox.vgrow="SOMETIMES">
|
||||
<content>
|
||||
<HBox>
|
||||
<children>
|
||||
<ImageView fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="hbox" styleClass="background" />
|
||||
</content>
|
||||
</ScrollPane>
|
||||
</children>
|
||||
</Pane>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</VBox>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
Reference in New Issue
Block a user