Ajout des cartes lieux en provenance de la bdd

This commit is contained in:
Paul Gross
2020-05-08 16:08:56 +02:00
parent 78f251d5f1
commit d6fe0f0d80
15 changed files with 212 additions and 72 deletions

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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<Carte,BufferedImage> 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<JoueurIHM>();
GestionnaireJeu gj = GestionnaireJeu.getGestionnaireJeu();
RessourceLoader rl = gj.getRessourceLoader();
Map<Integer, Joueur> 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<CarteLieu> cl = gj.getCartesLieux();
List<ImageView> 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<CarteLieu> cls, List<ImageView> 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<ImageView> getLieux() {
List<ImageView> views = new ArrayList<ImageView>();
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
*

View File

@ -18,7 +18,7 @@
<?import javafx.scene.shape.Circle?>
<?import javafx.scene.text.Font?>
<AnchorPane fx:id="rootPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" styleClass="background" stylesheets="@style/plateau.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ihm.controller.PlateauController">
<AnchorPane fx:id="rootPane" styleClass="background" stylesheets="@style/plateau.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ihm.controller.PlateauController">
<children>
<HBox alignment="CENTER" layoutX="14.0" spacing="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
@ -70,6 +70,9 @@
</FlowPane>
<Label styleClass="text" stylesheets="@style/plateau.css" text="Equipements" GridPane.columnIndex="2" />
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</GridPane>
<GridPane nodeOrientation="RIGHT_TO_LEFT" GridPane.columnIndex="1">
<columnConstraints>
@ -108,6 +111,9 @@
</FlowPane>
<Label styleClass="text" stylesheets="@style/plateau.css" text="Equipements" GridPane.columnIndex="2" />
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</GridPane>
</children>
<padding>
@ -167,6 +173,9 @@
</FlowPane>
<Label styleClass="text" stylesheets="@style/plateau.css" text="Equipements" GridPane.columnIndex="2" />
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</GridPane>
<GridPane nodeOrientation="RIGHT_TO_LEFT" GridPane.columnIndex="1">
<columnConstraints>
@ -205,17 +214,20 @@
</FlowPane>
<Label styleClass="text" stylesheets="@style/plateau.css" text="Equipements" GridPane.columnIndex="2" />
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</GridPane>
</children>
<padding>
<Insets bottom="25.0" />
</padding>
</GridPane>
<HBox alignment="CENTER" maxHeight="600.0" maxWidth="1200.0" spacing="50.0" VBox.vgrow="ALWAYS">
<HBox alignment="CENTER" prefHeight="366.0" prefWidth="810.0" spacing="50.0">
<children>
<VBox alignment="TOP_CENTER">
<children>
<HBox prefHeight="100.0" prefWidth="200.0" styleClass="carteLumiere" stylesheets="@style/plateau.css">
<HBox styleClass="carteLumiere" stylesheets="@style/plateau.css">
<children>
<ImageView fitHeight="97.8" fitWidth="70.05" pickOnBounds="true" preserveRatio="true" styleClass="background">
<image>
@ -249,19 +261,19 @@
</VBox>
<VBox alignment="CENTER" spacing="50.0">
<children>
<GridPane hgap="20.0" VBox.vgrow="ALWAYS">
<GridPane alignment="CENTER" hgap="20.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" />
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" />
<ColumnConstraints hgrow="ALWAYS" />
<ColumnConstraints />
<ColumnConstraints hgrow="ALWAYS" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
<RowConstraints />
</rowConstraints>
<children>
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
<ColumnConstraints />
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="SOMETIMES" />
@ -278,67 +290,79 @@
</GridPane>
<GridPane fx:id="gridPaneLieux" hgap="20.0" GridPane.columnIndex="1">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" />
<ColumnConstraints hgrow="SOMETIMES" />
<ColumnConstraints hgrow="SOMETIMES" />
<ColumnConstraints />
<ColumnConstraints />
<ColumnConstraints />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints />
</rowConstraints>
<children>
<HBox alignment="TOP_CENTER" styleClass="lieux" stylesheets="@style/plateau.css">
<HBox alignment="TOP_CENTER" maxHeight="-Infinity" maxWidth="-Infinity" spacing="5.0" styleClass="lieux" stylesheets="@style/plateau.css">
<children>
<StackPane>
<StackPane HBox.hgrow="NEVER">
<children>
<FlowPane prefHeight="200.0" prefWidth="200.0" />
<ImageView fitHeight="132.03" fitWidth="94.5675" pickOnBounds="true" preserveRatio="true" />
<ImageView fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
<FlowPane styleClass="lieu" />
</children>
</StackPane>
<StackPane layoutX="39.0" layoutY="12.0">
<StackPane layoutX="39.0" layoutY="12.0" HBox.hgrow="NEVER">
<children>
<FlowPane prefHeight="200.0" prefWidth="200.0" />
<ImageView fitHeight="132.03" fitWidth="94.5675" pickOnBounds="true" preserveRatio="true" />
<ImageView fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
<FlowPane />
</children>
</StackPane>
</children>
<GridPane.margin>
<Insets />
</GridPane.margin>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</HBox>
<HBox alignment="BOTTOM_CENTER" styleClass="lieux" stylesheets="@style/plateau.css" GridPane.columnIndex="1">
<HBox alignment="BOTTOM_CENTER" spacing="5.0" styleClass="lieux" stylesheets="@style/plateau.css" GridPane.columnIndex="1">
<children>
<StackPane>
<StackPane HBox.hgrow="NEVER">
<children>
<FlowPane prefHeight="200.0" prefWidth="200.0" />
<ImageView fitHeight="132.03" fitWidth="94.5675" pickOnBounds="true" preserveRatio="true" />
<ImageView fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
<FlowPane />
</children>
</StackPane>
<StackPane>
<StackPane HBox.hgrow="NEVER">
<children>
<FlowPane prefHeight="200.0" prefWidth="200.0" />
<ImageView fitHeight="132.03" fitWidth="94.5675" pickOnBounds="true" preserveRatio="true" />
<ImageView fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
<FlowPane />
</children>
</StackPane>
</children>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</HBox>
<HBox alignment="TOP_CENTER" styleClass="lieux" stylesheets="@style/plateau.css" GridPane.columnIndex="2">
<HBox alignment="TOP_CENTER" spacing="5.0" styleClass="lieux" stylesheets="@style/plateau.css" GridPane.columnIndex="2">
<children>
<StackPane>
<StackPane HBox.hgrow="NEVER">
<children>
<FlowPane prefHeight="200.0" prefWidth="200.0" />
<ImageView fitHeight="132.03" fitWidth="94.5675" pickOnBounds="true" preserveRatio="true" />
<ImageView fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
<FlowPane />
</children>
</StackPane>
<StackPane>
<StackPane HBox.hgrow="NEVER">
<children>
<FlowPane prefHeight="200.0" prefWidth="200.0" />
<ImageView fitHeight="132.03" fitWidth="94.5675" pickOnBounds="true" preserveRatio="true" />
<ImageView fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
<FlowPane />
</children>
</StackPane>
</children>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</HBox>
</children>
</GridPane>
<GridPane GridPane.columnIndex="2">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
<ColumnConstraints />
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="SOMETIMES" />
@ -633,6 +657,9 @@
</FlowPane>
<Label styleClass="text" stylesheets="@style/plateau.css" text="Equipements" GridPane.columnIndex="2" />
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</GridPane>
<GridPane nodeOrientation="RIGHT_TO_LEFT" GridPane.columnIndex="1">
<columnConstraints>
@ -671,6 +698,9 @@
</FlowPane>
<Label styleClass="text" stylesheets="@style/plateau.css" text="Equipements" GridPane.columnIndex="2" />
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</GridPane>
</children>
<padding>
@ -727,6 +757,9 @@
</FlowPane>
<Label styleClass="text" stylesheets="@style/plateau.css" text="Equipements" GridPane.columnIndex="2" />
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</GridPane>
<GridPane nodeOrientation="RIGHT_TO_LEFT" GridPane.columnIndex="1">
<columnConstraints>
@ -765,6 +798,9 @@
</FlowPane>
<Label styleClass="text" stylesheets="@style/plateau.css" text="Equipements" GridPane.columnIndex="2" />
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</GridPane>
</children>
<padding>

View File

@ -77,4 +77,9 @@
-fx-border-color: #e2e2e2;
-fx-border-width: 2;
-fx-background-radius: 0;
}
.pane{
}