Ajout de popup dragables et stylés
This commit is contained in:
parent
c502639c82
commit
22a0c17da2
@ -10,7 +10,7 @@ import javafx.stage.Stage;
|
|||||||
public class Main extends Application{
|
public class Main extends Application{
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) throws Exception{
|
public void start(Stage primaryStage) throws Exception{
|
||||||
Parent root = FXMLLoader.load(getClass().getResource("ressources/Plateau.fxml"));
|
Parent root = FXMLLoader.load(getClass().getResource("ressources/Choix_joueur.fxml"));
|
||||||
primaryStage.setTitle("Shadow Hunters");
|
primaryStage.setTitle("Shadow Hunters");
|
||||||
primaryStage.setScene(new Scene(root));
|
primaryStage.setScene(new Scene(root));
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
|
@ -1,25 +1,85 @@
|
|||||||
package ihm;
|
package ihm;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.Window.Type;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
import javafx.embed.swing.JFXPanel;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.input.MouseEvent;
|
||||||
import javafx.stage.Modality;
|
import javafx.stage.Modality;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import javafx.stage.StageStyle;
|
||||||
|
|
||||||
public class PopUp {
|
public class PopUp{
|
||||||
private Scene scene;
|
private Scene scene;
|
||||||
private Stage popupwindow;
|
private Stage popup;
|
||||||
|
|
||||||
|
private double xOffSet = 0;
|
||||||
|
private double yOffSet = 0;
|
||||||
|
|
||||||
public PopUp (Parent p, String titre) {
|
public PopUp (Parent p, String titre) {
|
||||||
|
|
||||||
popupwindow = new Stage();
|
|
||||||
popupwindow.initModality(Modality.APPLICATION_MODAL);
|
popup = new Stage();
|
||||||
popupwindow.setTitle(titre);
|
|
||||||
|
|
||||||
|
|
||||||
|
popup.initModality(Modality.NONE);
|
||||||
|
|
||||||
|
popup.initStyle(StageStyle.UNDECORATED);
|
||||||
|
|
||||||
|
popup.setTitle(titre);
|
||||||
|
|
||||||
scene = new Scene(p);
|
scene = new Scene(p);
|
||||||
|
|
||||||
|
p.setOnMousePressed(new EventHandler<MouseEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(MouseEvent event){
|
||||||
|
|
||||||
|
xOffSet = event.getSceneX();
|
||||||
|
yOffSet = event.getSceneY();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
p.setOnMouseDragged(new EventHandler<MouseEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(MouseEvent event){
|
||||||
|
|
||||||
|
popup.setX(event.getScreenX() - xOffSet);
|
||||||
|
popup.setY(event.getScreenY() - yOffSet);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
popup.focusedProperty().addListener((obs,wasFocused,isNowFocused) -> {
|
||||||
|
|
||||||
|
if(!isNowFocused) {
|
||||||
|
popup.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void display() {
|
public void display() {
|
||||||
popupwindow.setScene(scene);
|
|
||||||
popupwindow.showAndWait();
|
popup.setScene(scene);
|
||||||
|
|
||||||
|
popup.showAndWait();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,16 +12,15 @@ import javafx.fxml.Initializable;
|
|||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.layout.BorderPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.Pane;
|
|
||||||
|
|
||||||
public class MenuController implements Initializable{
|
public class MenuController implements Initializable{
|
||||||
@FXML private Pane rootPane;
|
@FXML private AnchorPane rootPane;
|
||||||
@FXML private ImageView titre;
|
@FXML private ImageView titre;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
FileInputStream input;
|
FileInputStream input;
|
||||||
try {
|
try {
|
||||||
input = new FileInputStream("src\\ihm\\ressources\\img\\logo.png");
|
input = new FileInputStream("src\\ihm\\ressources\\img\\logo.png");
|
||||||
@ -34,8 +33,8 @@ public class MenuController implements Initializable{
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void commencerPartie(MouseEvent mouseEvent) throws IOException{
|
public void commencerPartie(MouseEvent mouseEvent) throws IOException{
|
||||||
System.out.println("Passage à l'écran de choix des joueurs");
|
System.out.println("Passage à l'écran de choix des joueurs");
|
||||||
BorderPane pane = FXMLLoader.load(getClass().getResource("../ressources/Choix_joueur.fxml"));
|
AnchorPane pane = FXMLLoader.load(getClass().getResource("../ressources/Choix_joueur.fxml"));
|
||||||
rootPane.getChildren().setAll(pane);
|
rootPane.getChildren().setAll(pane);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public class PlayersController implements Initializable{
|
|||||||
private List<TextField> txt = new ArrayList<TextField>();
|
private List<TextField> txt = new ArrayList<TextField>();
|
||||||
private List<CheckBox> ia = new ArrayList<CheckBox>();
|
private List<CheckBox> ia = new ArrayList<CheckBox>();
|
||||||
|
|
||||||
private List<Joueur> joueur = new ArrayList<Joueur>();
|
private List<Joueur> joueurs = new ArrayList<Joueur>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,22 +78,26 @@ public class PlayersController implements Initializable{
|
|||||||
@FXML
|
@FXML
|
||||||
public void commencerJeux(MouseEvent mouseEvent) throws IOException{
|
public void commencerJeux(MouseEvent mouseEvent) throws IOException{
|
||||||
//ajout des joueurs finalement selectionner
|
//ajout des joueurs finalement selectionner
|
||||||
int nbJoueur = 0;
|
int nbJoueurs = 0;
|
||||||
|
|
||||||
for (HBox hb : ligne) {
|
for (HBox hb : ligne) {
|
||||||
|
|
||||||
TextField tf = (TextField) hb.getChildren().get(0);
|
TextField tf = (TextField) hb.getChildren().get(0);
|
||||||
CheckBox cb = (CheckBox) hb.getChildren().get(2);
|
CheckBox cb = (CheckBox) hb.getChildren().get(2);
|
||||||
Joueur j;
|
Joueur j;
|
||||||
|
|
||||||
if (tf.isEditable()) {
|
if (tf.isEditable()) {
|
||||||
if(cb.isSelected())
|
if(cb.isSelected()) {
|
||||||
j = new JoueurVirtuel(tf.getText());
|
joueurs.add(new Joueur(tf.getText()));
|
||||||
else
|
}
|
||||||
j = new Joueur(tf.getText());
|
else {
|
||||||
nbJoueur++;
|
joueurs.add(new JoueurVirtuel(tf.getText()));
|
||||||
}else j = null;
|
}
|
||||||
joueur.add(j);
|
nbJoueurs++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbJoueur <4) {
|
if (nbJoueurs < 4) {
|
||||||
Alert alert = new Alert(AlertType.WARNING, "Il faut au moins de 4 joueurs !");
|
Alert alert = new Alert(AlertType.WARNING, "Il faut au moins de 4 joueurs !");
|
||||||
alert.showAndWait();
|
alert.showAndWait();
|
||||||
}else {
|
}else {
|
||||||
@ -102,12 +106,14 @@ public class PlayersController implements Initializable{
|
|||||||
Parent root = loader.load();
|
Parent root = loader.load();
|
||||||
|
|
||||||
PlateauController pc = loader.getController();
|
PlateauController pc = loader.getController();
|
||||||
pc.showInformation(joueur);
|
pc.showInformation(joueurs);
|
||||||
|
|
||||||
rootPane.getChildren().setAll(root);
|
rootPane.getChildren().setAll(root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Autorise a <EFBFBD>crire dans le text filed le nom du joueur ajouter
|
* Autorise a <EFBFBD>crire dans le text filed le nom du joueur ajouter
|
||||||
*
|
*
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<children>
|
<children>
|
||||||
<BorderPane fx:id="root" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1280.0" styleClass="background" stylesheets="@style/plateau.css" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<BorderPane fx:id="root" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1280.0" styleClass="background" stylesheets="@style/plateau.css" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<top>
|
<top>
|
||||||
<HBox alignment="CENTER" prefHeight="149.0" prefWidth="1280.0" BorderPane.alignment="CENTER">
|
<HBox alignment="CENTER" prefHeight="149.0" prefWidth="1343.0" BorderPane.alignment="CENTER">
|
||||||
<children>
|
<children>
|
||||||
<VBox fx:id="joueur1" alignment="CENTER" prefHeight="164.0" prefWidth="212.0" rotate="180.0">
|
<VBox fx:id="joueur1" alignment="CENTER" prefHeight="164.0" prefWidth="212.0" rotate="180.0">
|
||||||
<children>
|
<children>
|
||||||
|
@ -1,15 +1,34 @@
|
|||||||
package main;
|
package main;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import effet.Effet;
|
import effet.Effet;
|
||||||
|
|
||||||
public class GestionnaireJeu {
|
public class GestionnaireJeu {
|
||||||
|
|
||||||
|
|
||||||
private Plateau plateau;
|
private Plateau plateau;
|
||||||
private View view;
|
private View view;
|
||||||
|
|
||||||
public GestionnaireJeu (Plateau p) {
|
|
||||||
plateau = p;
|
|
||||||
|
public GestionnaireJeu() {
|
||||||
|
this.plateau = new Plateau(new ArrayList<Joueur>());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
switch(1){
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
lancerPartie();
|
||||||
|
case 2:
|
||||||
|
lancerConfiguration();
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Plateau getPlateau() {
|
public Plateau getPlateau() {
|
||||||
@ -20,11 +39,15 @@ public class GestionnaireJeu {
|
|||||||
this.plateau = plateau;
|
this.plateau = plateau;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lancerPartie(Configuration c) {
|
public static void lancerPartie() {
|
||||||
//TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Configuration lancerConfiguration() {
|
public void jouer(Configuration c) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Configuration lancerConfiguration() {
|
||||||
//TODO
|
//TODO
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,25 @@
|
|||||||
package main;
|
package main;
|
||||||
|
|
||||||
public class View {
|
import javafx.application.Application;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
public class View extends Application{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(Stage primaryStage) throws Exception{
|
||||||
|
Parent root = FXMLLoader.load(getClass().getResource("ressources/Plateau.fxml"));
|
||||||
|
primaryStage.setTitle("Shadow Hunters");
|
||||||
|
primaryStage.setScene(new Scene(root));
|
||||||
|
primaryStage.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
launch(args);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user