From d368228aabf510694e0e312d8af31f226b1e9072 Mon Sep 17 00:00:00 2001 From: Chiara Date: Thu, 23 Apr 2020 13:47:40 +0200 Subject: [PATCH] responsive --- src/ihm/Main.java | 5 +-- src/ihm/controller/MenuController.java | 13 ++++--- src/ihm/controller/PlateauController.java | 3 ++ src/ihm/controller/PlayersController.java | 15 ++++---- src/ihm/ressources/Choix_joueur.fxml | 5 ++- src/ihm/ressources/Menu.fxml | 44 +++++++++++++++-------- src/main/View.java | 2 +- 7 files changed, 56 insertions(+), 31 deletions(-) diff --git a/src/ihm/Main.java b/src/ihm/Main.java index d8bf3e8..564545f 100644 --- a/src/ihm/Main.java +++ b/src/ihm/Main.java @@ -3,17 +3,18 @@ package ihm; import javafx.application.Application; import javafx.fxml.FXMLLoader; -import javafx.scene.Parent; import javafx.scene.Scene; +import javafx.scene.layout.AnchorPane; import javafx.stage.Stage; public class Main extends Application{ @Override public void start(Stage primaryStage) throws Exception{ System.out.println("Lancement de l'application"); - Parent root = FXMLLoader.load(getClass().getResource("ressources/Menu.fxml")); + AnchorPane root = FXMLLoader.load(getClass().getResource("ressources/Menu.fxml")); primaryStage.setTitle("Shadow Hunters"); primaryStage.setScene(new Scene(root)); + primaryStage.centerOnScreen(); primaryStage.show(); } diff --git a/src/ihm/controller/MenuController.java b/src/ihm/controller/MenuController.java index eba3b9f..57e7d2a 100644 --- a/src/ihm/controller/MenuController.java +++ b/src/ihm/controller/MenuController.java @@ -9,19 +9,20 @@ import java.util.ResourceBundle; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; +import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.input.MouseEvent; import javafx.scene.layout.AnchorPane; -import javafx.scene.layout.Pane; +import javafx.stage.Stage; +import javafx.scene.Node; public class MenuController implements Initializable{ - @FXML private Pane rootPane; + @FXML private AnchorPane rootPane; @FXML private ImageView titre; @Override public void initialize(URL arg0, ResourceBundle arg1) { - FileInputStream input; try { input = new FileInputStream("src\\ihm\\ressources\\img\\logo.png"); @@ -36,8 +37,10 @@ public class MenuController implements Initializable{ public void commencerPartie(MouseEvent mouseEvent) throws IOException{ System.out.println("Passage à  l'écran de choix des joueurs"); AnchorPane pane = FXMLLoader.load(getClass().getResource("../ressources/Choix_joueur.fxml")); - rootPane.getChildren().setAll(pane); - + Scene scene = new Scene(pane); + Stage appStage = (Stage) ((Node) mouseEvent.getSource()).getScene().getWindow(); + appStage.setScene(scene); + appStage.show(); } public void afficherRegle(MouseEvent mouseEvent) { diff --git a/src/ihm/controller/PlateauController.java b/src/ihm/controller/PlateauController.java index a2254c7..590e3f5 100644 --- a/src/ihm/controller/PlateauController.java +++ b/src/ihm/controller/PlateauController.java @@ -19,6 +19,7 @@ import javafx.scene.control.Label; import javafx.scene.layout.VBox; import javafx.scene.layout.HBox; import main.Joueur; +import main.View; public class PlateauController implements Initializable { private List listJoueur = new ArrayList(); @@ -83,6 +84,8 @@ public class PlateauController implements Initializable { for (Label l : factionPerso) { l.setText("???"); } + + listJoueur = View.getJoueurs(); } /** diff --git a/src/ihm/controller/PlayersController.java b/src/ihm/controller/PlayersController.java index 55a326b..be5eded 100644 --- a/src/ihm/controller/PlayersController.java +++ b/src/ihm/controller/PlayersController.java @@ -11,21 +11,23 @@ import ihm.Couple; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; +import javafx.scene.Node; 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.input.MouseEvent; +import javafx.scene.layout.AnchorPane; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; -import main.Configuration; -import main.View; +import javafx.stage.Stage; public class PlayersController implements Initializable{ - @FXML private BorderPane rootPane; + @FXML private AnchorPane rootPane; @FXML private HBox hb1; @FXML private HBox hb2; @@ -112,11 +114,12 @@ public class PlayersController implements Initializable{ FXMLLoader loader = new FXMLLoader(getClass().getResource("../ressources/Plateau.fxml")); Parent root = loader.load(); - PlateauController pc = loader.getController(); pc.showInformation(joueurs); - - rootPane.getChildren().setAll(root); + Scene scene = new Scene(root); + Stage appStage = (Stage) ((Node) mouseEvent.getSource()).getScene().getWindow(); + appStage.setScene(scene); + appStage.show(); } } diff --git a/src/ihm/ressources/Choix_joueur.fxml b/src/ihm/ressources/Choix_joueur.fxml index b017978..48b816b 100644 --- a/src/ihm/ressources/Choix_joueur.fxml +++ b/src/ihm/ressources/Choix_joueur.fxml @@ -11,10 +11,9 @@ - - + - + diff --git a/src/ihm/ressources/Menu.fxml b/src/ihm/ressources/Menu.fxml index b88c49f..f3d5c52 100644 --- a/src/ihm/ressources/Menu.fxml +++ b/src/ihm/ressources/Menu.fxml @@ -1,22 +1,38 @@ + - + + - + - - - + + + + + + + + + + + - + diff --git a/src/main/View.java b/src/main/View.java index 50c9656..0b18186 100644 --- a/src/main/View.java +++ b/src/main/View.java @@ -23,7 +23,7 @@ public class View{ gj.setConfiguration(c); } - public List getJoueurs() { + public static List getJoueurs() { return null; } }