passage de noms players controller ->^plateaucontroller
This commit is contained in:
parent
fd6904f58a
commit
0ae1d3e242
@ -11,15 +11,16 @@ import ihm.PopUp;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import main.Joueur;
|
||||
|
||||
public class PlateauController implements Initializable {
|
||||
@FXML private BorderPane root;
|
||||
|
||||
private List<Joueur> listJoueur = new ArrayList<Joueur>();
|
||||
private List<VBox> vboxJoueur = new ArrayList<VBox>();
|
||||
@ -27,6 +28,7 @@ public class PlateauController implements Initializable {
|
||||
private List<Button> btnCartePerso = new ArrayList<Button>();
|
||||
private List<Label> nomPerso = new ArrayList<Label>();
|
||||
private List<Label> factionPerso = new ArrayList<Label>();
|
||||
private List<Label> nomJoueur = new ArrayList<Label>();
|
||||
|
||||
@FXML private VBox joueur1;
|
||||
@FXML private VBox joueur2;
|
||||
@ -36,8 +38,7 @@ public class PlateauController implements Initializable {
|
||||
@FXML private VBox joueur6;
|
||||
@FXML private VBox joueur7;
|
||||
@FXML private VBox joueur8;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* initialise les données du plateau
|
||||
*/
|
||||
@ -58,6 +59,7 @@ public class PlateauController implements Initializable {
|
||||
for (VBox vbox : vboxJoueur) {
|
||||
nomPerso.add((Label) vbox.getChildren().get(1));
|
||||
factionPerso.add((Label) vbox.getChildren().get(0));
|
||||
nomJoueur.add((Label) vbox.getChildren().get(2));
|
||||
HBox enfant = (HBox) vbox.getChildren().get(3);
|
||||
btnCartePerso.add((Button) enfant.getChildren().get(0));
|
||||
btnRevelation.add((Button) enfant.getChildren().get(1));
|
||||
@ -106,6 +108,13 @@ public class PlateauController implements Initializable {
|
||||
popup.display();
|
||||
}
|
||||
|
||||
public void showInformation(List<Joueur> j) {
|
||||
System.out.println("Ecriture des noms des joueurs");
|
||||
for (int i=0; i<j.size(); i++) {
|
||||
nomJoueur.get(i).setText(j.get(i).getNom());
|
||||
}
|
||||
}
|
||||
|
||||
public void attribuerPerso(List<Joueur> lj) {
|
||||
|
||||
}
|
||||
|
@ -1,83 +1,138 @@
|
||||
package ihm.controller;
|
||||
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Alert.AlertType;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.TextInputControl;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
import main.Joueur;
|
||||
import main.JoueurVirtuel;
|
||||
|
||||
public class PlayersController implements Initializable{
|
||||
|
||||
@FXML private BorderPane rootPane;
|
||||
@FXML private TextField tf;
|
||||
@FXML private VBox vb1;
|
||||
@FXML private VBox vb2;
|
||||
private HBox hb10;
|
||||
private HBox hb11;
|
||||
private HBox hb12;
|
||||
private HBox hb13;
|
||||
private TextField tf0;
|
||||
private Button btn;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@FXML private HBox hb1;
|
||||
@FXML private HBox hb2;
|
||||
@FXML private HBox hb3;
|
||||
@FXML private HBox hb4;
|
||||
@FXML private HBox hb5;
|
||||
@FXML private HBox hb6;
|
||||
@FXML private HBox hb7;
|
||||
@FXML private HBox hb8;
|
||||
|
||||
private List<HBox> ligne = new ArrayList<HBox>();
|
||||
private List<Button> plus = new ArrayList<Button>();
|
||||
private List<TextField> txt = new ArrayList<TextField>();
|
||||
private List<CheckBox> ia = new ArrayList<CheckBox>();
|
||||
|
||||
private List<Joueur> joueur = new ArrayList<Joueur>();
|
||||
|
||||
|
||||
/**
|
||||
* recupère chaque bouton textField et Checkebox a partir des hbox
|
||||
*/
|
||||
@Override
|
||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||
for(int i=0;i<4;i++) {
|
||||
hb10=(HBox) vb1.getChildren().get(i);
|
||||
tf0=(TextField) hb10.getChildren().get(0);
|
||||
|
||||
tf0.setEditable(false);
|
||||
|
||||
}
|
||||
for(int i=0;i<4;i++) {
|
||||
hb10=(HBox) vb1.getChildren().get(i);
|
||||
tf0=(TextField) hb10.getChildren().get(0);
|
||||
btn=(Button) hb10.getChildren().get(1);
|
||||
btn.setOnAction((e) -> {
|
||||
tf0.setEditable(true);});
|
||||
|
||||
ligne.add(hb1);
|
||||
ligne.add(hb2);
|
||||
ligne.add(hb3);
|
||||
ligne.add(hb4);
|
||||
ligne.add(hb5);
|
||||
ligne.add(hb6);
|
||||
ligne.add(hb7);
|
||||
ligne.add(hb8);
|
||||
for (HBox hb : ligne) {
|
||||
txt.add((TextField) hb.getChildren().get(0));
|
||||
plus.add((Button) hb.getChildren().get(1));
|
||||
ia.add((CheckBox) hb.getChildren().get(2));
|
||||
}
|
||||
|
||||
int i=0;
|
||||
for (Button btn : plus) {
|
||||
int compteur = i;
|
||||
btn.setOnAction(e -> {ajoutJoueur(compteur);});
|
||||
i++;
|
||||
}
|
||||
|
||||
for (TextField tf : txt) {
|
||||
tf.setEditable(false);
|
||||
tf.setStyle("-fx-background-color: silver;");
|
||||
}
|
||||
}
|
||||
//liaison.put( (Button)vb11.getChildren().get(i), maListe);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Partie2 pas prendre en compte pour le moment
|
||||
|
||||
|
||||
@FXML
|
||||
public void commencerJeux(MouseEvent mouseEvent) throws IOException{
|
||||
System.out.println("Lancement du jeu...");
|
||||
BorderPane pane = FXMLLoader.load(getClass().getResource("../ressources/Plateau.fxml"));
|
||||
rootPane.getChildren().setAll(pane);
|
||||
}
|
||||
@FXML
|
||||
public void ajoutJoueur(MouseEvent mouseEvent) throws IOException{
|
||||
tf.setEditable(true);
|
||||
//ajout des joueurs finalement selectionner
|
||||
for (HBox hb : ligne) {
|
||||
TextField tf = (TextField) hb.getChildren().get(0);
|
||||
CheckBox cb = (CheckBox) hb.getChildren().get(2);
|
||||
Joueur j;
|
||||
if (tf.isEditable()) {
|
||||
if(cb.isSelected())
|
||||
j = new JoueurVirtuel(tf.getText());
|
||||
else
|
||||
j = new Joueur(tf.getText());
|
||||
|
||||
joueur.add(j);
|
||||
}
|
||||
}
|
||||
|
||||
if (joueur.size() <4) {
|
||||
Alert alert = new Alert(AlertType.WARNING, "Vous avez moins de 4 joueurs !");
|
||||
alert.showAndWait();
|
||||
}else {
|
||||
System.out.println("Lancement du jeu...");
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("../ressources/Plateau.fxml"));
|
||||
Parent root = loader.load();
|
||||
|
||||
PlateauController pc = loader.getController();
|
||||
pc.showInformation(joueur);
|
||||
|
||||
rootPane.getChildren().setAll(root);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Autorise a écrire dans le text filed le nom du joueur ajouter
|
||||
*
|
||||
* @param indice : pour savoir quel bouton a été cliqué
|
||||
*/
|
||||
public void ajoutJoueur(int indice){
|
||||
System.out.println("Ajout du joueur " + (indice+1));
|
||||
plus.get(indice).setText("- ");
|
||||
txt.get(indice).setEditable(true);
|
||||
txt.get(indice).setStyle("-fx-background-color: white;");
|
||||
plus.get(indice).setOnAction(e -> {enleverJoueur(indice);});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retire le joueur précedemnt ajouter
|
||||
*
|
||||
* @param indice : pour savoir quel bouton a été cliqué
|
||||
*/
|
||||
public void enleverJoueur(int indice) {
|
||||
System.out.println("Desistement du joueur " + (indice+1));
|
||||
plus.get(indice).setText("+");
|
||||
txt.get(indice).setEditable(false);
|
||||
txt.get(indice).setText("");
|
||||
txt.get(indice).setStyle("-fx-background-color: silver;");
|
||||
plus.get(indice).setOnAction(e -> {ajoutJoueur(indice);});
|
||||
}
|
||||
}
|
||||
|
@ -41,31 +41,9 @@
|
||||
</VBox>
|
||||
</top>
|
||||
<left>
|
||||
<VBox fx:id="vb1" alignment="CENTER" prefHeight="559.0" prefWidth="642.0" BorderPane.alignment="CENTER">
|
||||
<VBox alignment="CENTER" prefHeight="559.0" prefWidth="642.0" BorderPane.alignment="CENTER">
|
||||
<children>
|
||||
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
|
||||
<children>
|
||||
<TextField fx:id="tf">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
</TextField>
|
||||
<Button mnemonicParsing="false" styleClass="bouton" stylesheets="@style/menu.css" text="+">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
<HBox.margin>
|
||||
<Insets left="10.0" right="10.0" />
|
||||
</HBox.margin>
|
||||
</Button>
|
||||
<CheckBox mnemonicParsing="false">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
</CheckBox>
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
|
||||
<HBox fx:id="hb1" alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
|
||||
<children>
|
||||
<TextField>
|
||||
<font>
|
||||
@ -87,7 +65,7 @@
|
||||
</CheckBox>
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
|
||||
<HBox fx:id="hb2" alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
|
||||
<children>
|
||||
<TextField>
|
||||
<font>
|
||||
@ -109,7 +87,29 @@
|
||||
</CheckBox>
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
|
||||
<HBox fx:id="hb3" alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
|
||||
<children>
|
||||
<TextField>
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
</TextField>
|
||||
<Button mnemonicParsing="false" styleClass="bouton" stylesheets="@style/menu.css" text="+">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
<HBox.margin>
|
||||
<Insets left="10.0" right="10.0" />
|
||||
</HBox.margin>
|
||||
</Button>
|
||||
<CheckBox mnemonicParsing="false">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
</CheckBox>
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="hb4" alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
|
||||
<children>
|
||||
<TextField>
|
||||
<font>
|
||||
@ -135,9 +135,9 @@
|
||||
</VBox>
|
||||
</left>
|
||||
<right>
|
||||
<VBox fx:id="vb2" alignment="CENTER" prefHeight="559.0" prefWidth="694.0" BorderPane.alignment="CENTER">
|
||||
<VBox alignment="CENTER" prefHeight="559.0" prefWidth="694.0" BorderPane.alignment="CENTER">
|
||||
<children>
|
||||
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
|
||||
<HBox fx:id="hb5" alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
|
||||
<children>
|
||||
<TextField>
|
||||
<font>
|
||||
@ -159,7 +159,7 @@
|
||||
</CheckBox>
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
|
||||
<HBox fx:id="hb6" alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
|
||||
<children>
|
||||
<TextField>
|
||||
<font>
|
||||
@ -181,7 +181,7 @@
|
||||
</CheckBox>
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
|
||||
<HBox fx:id="hb7" alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
|
||||
<children>
|
||||
<TextField>
|
||||
<font>
|
||||
@ -203,7 +203,7 @@
|
||||
</CheckBox>
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
|
||||
<HBox fx:id="hb8" alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
|
||||
<children>
|
||||
<TextField>
|
||||
<font>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.shape.Circle?>
|
||||
|
||||
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1280.0" 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">
|
||||
<BorderPane fx:id="root" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1280.0" 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">
|
||||
<top>
|
||||
<HBox alignment="CENTER" prefHeight="149.0" prefWidth="1280.0" BorderPane.alignment="CENTER">
|
||||
<children>
|
||||
|
@ -194,5 +194,9 @@ public class Joueur {
|
||||
public CarteLieu getCarteLieu() {
|
||||
return this.carteLieu;
|
||||
}
|
||||
|
||||
public String getNom() {
|
||||
return this.nom;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user