From e829dc7de61d172781f5a6486e5709cecacbf2f5 Mon Sep 17 00:00:00 2001 From: Chiara Date: Mon, 20 Apr 2020 13:46:18 +0200 Subject: [PATCH] =?UTF-8?q?cr=C3=A9ation=20de=20la=20classe=20popup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ihm/PopUp.java | 24 +++++++++++++++ src/ihm/controller/PlateauController.java | 36 +++++++++++++++++++++++ src/ihm/controller/PlayersController.java | 3 +- src/ihm/ressources/Choix_joueur.fxml | 4 +-- src/ihm/ressources/Plateau.fxml | 18 ++++++------ 5 files changed, 73 insertions(+), 12 deletions(-) create mode 100644 src/ihm/PopUp.java create mode 100644 src/ihm/controller/PlateauController.java diff --git a/src/ihm/PopUp.java b/src/ihm/PopUp.java new file mode 100644 index 0000000..9180698 --- /dev/null +++ b/src/ihm/PopUp.java @@ -0,0 +1,24 @@ +package ihm; + +import javafx.scene.Scene; +import javafx.scene.layout.Pane; +import javafx.stage.Modality; +import javafx.stage.Stage; + +public class PopUp { + private Scene scene; + private Stage popupwindow; + + public PopUp (Pane p, String titre) { + popupwindow = new Stage(); + popupwindow.initModality(Modality.APPLICATION_MODAL); + popupwindow.setTitle(titre); + + scene = new Scene(p); + } + + public void display() { + popupwindow.setScene(scene); + popupwindow.showAndWait(); + } +} diff --git a/src/ihm/controller/PlateauController.java b/src/ihm/controller/PlateauController.java new file mode 100644 index 0000000..9a1a968 --- /dev/null +++ b/src/ihm/controller/PlateauController.java @@ -0,0 +1,36 @@ +package ihm.controller; + +import java.io.IOException; +import java.net.URL; +import java.util.ResourceBundle; + +import ihm.PopUp; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.control.Alert; +import javafx.scene.control.Alert.AlertType; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.Pane; + +public class PlateauController implements Initializable{ + + @Override + public void initialize(URL arg0, ResourceBundle arg1) { + // TODO Auto-generated method stub + + } + + /** + * Affiche aux yeux de tous la carte personnage du joueur + * + * @param mouseEvent : clique sur le bouton + * @throws IOException + */ + public void seReveler(MouseEvent mouseEvent) throws IOException { + System.out.println("Le joueur ... se revèle"); + Pane pane = FXMLLoader.load(getClass().getResource("../ressources/Reveler_son_identite.fxml")); + PopUp popup = new PopUp(pane, "reveler son identité"); + popup.display(); + } +} diff --git a/src/ihm/controller/PlayersController.java b/src/ihm/controller/PlayersController.java index 2298c74..cd10bdf 100644 --- a/src/ihm/controller/PlayersController.java +++ b/src/ihm/controller/PlayersController.java @@ -7,6 +7,7 @@ import java.util.ResourceBundle; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; +import javafx.scene.control.TextField; import javafx.scene.input.MouseEvent; import javafx.scene.layout.BorderPane; import javafx.scene.layout.Pane; @@ -24,7 +25,7 @@ public class PlayersController implements Initializable{ @FXML public void commencerJeux(MouseEvent mouseEvent) throws IOException{ System.out.println("Lancement du jeu..."); - Pane pane = FXMLLoader.load(getClass().getResource("../ressources/Plateau.fxml")); + BorderPane pane = FXMLLoader.load(getClass().getResource("../ressources/Plateau.fxml")); rootPane.getChildren().setAll(pane); } } diff --git a/src/ihm/ressources/Choix_joueur.fxml b/src/ihm/ressources/Choix_joueur.fxml index 560e5a0..ee7bed9 100644 --- a/src/ihm/ressources/Choix_joueur.fxml +++ b/src/ihm/ressources/Choix_joueur.fxml @@ -33,7 +33,7 @@ -