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{
|
||||
@Override
|
||||
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.setScene(new Scene(root));
|
||||
primaryStage.show();
|
||||
|
@ -1,25 +1,85 @@
|
||||
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.Scene;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
|
||||
public class PopUp{
|
||||
private Scene scene;
|
||||
private Stage popupwindow;
|
||||
private Stage popup;
|
||||
|
||||
private double xOffSet = 0;
|
||||
private double yOffSet = 0;
|
||||
|
||||
public PopUp (Parent p, String titre) {
|
||||
|
||||
popupwindow = new Stage();
|
||||
popupwindow.initModality(Modality.APPLICATION_MODAL);
|
||||
popupwindow.setTitle(titre);
|
||||
|
||||
popup = new Stage();
|
||||
|
||||
|
||||
|
||||
popup.initModality(Modality.NONE);
|
||||
|
||||
popup.initStyle(StageStyle.UNDECORATED);
|
||||
|
||||
popup.setTitle(titre);
|
||||
|
||||
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() {
|
||||
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.ImageView;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
|
||||
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) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
FileInputStream input;
|
||||
try {
|
||||
input = new FileInputStream("src\\ihm\\ressources\\img\\logo.png");
|
||||
@ -34,8 +33,8 @@ public class MenuController implements Initializable{
|
||||
|
||||
@FXML
|
||||
public void commencerPartie(MouseEvent mouseEvent) throws IOException{
|
||||
System.out.println("Passage à l'écran de choix des joueurs");
|
||||
BorderPane pane = FXMLLoader.load(getClass().getResource("../ressources/Choix_joueur.fxml"));
|
||||
System.out.println("Passage à l'écran de choix des joueurs");
|
||||
AnchorPane pane = FXMLLoader.load(getClass().getResource("../ressources/Choix_joueur.fxml"));
|
||||
rootPane.getChildren().setAll(pane);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class PlayersController implements Initializable{
|
||||
private List<TextField> txt = new ArrayList<TextField>();
|
||||
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
|
||||
public void commencerJeux(MouseEvent mouseEvent) throws IOException{
|
||||
//ajout des joueurs finalement selectionner
|
||||
int nbJoueur = 0;
|
||||
int nbJoueurs = 0;
|
||||
|
||||
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());
|
||||
nbJoueur++;
|
||||
}else j = null;
|
||||
joueur.add(j);
|
||||
if(cb.isSelected()) {
|
||||
joueurs.add(new Joueur(tf.getText()));
|
||||
}
|
||||
else {
|
||||
joueurs.add(new JoueurVirtuel(tf.getText()));
|
||||
}
|
||||
nbJoueurs++;
|
||||
}
|
||||
}
|
||||
|
||||
if (nbJoueur <4) {
|
||||
if (nbJoueurs < 4) {
|
||||
Alert alert = new Alert(AlertType.WARNING, "Il faut au moins de 4 joueurs !");
|
||||
alert.showAndWait();
|
||||
}else {
|
||||
@ -102,12 +106,14 @@ public class PlayersController implements Initializable{
|
||||
Parent root = loader.load();
|
||||
|
||||
PlateauController pc = loader.getController();
|
||||
pc.showInformation(joueur);
|
||||
pc.showInformation(joueurs);
|
||||
|
||||
rootPane.getChildren().setAll(root);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Autorise a <EFBFBD>crire dans le text filed le nom du joueur ajouter
|
||||
*
|
||||
|
@ -16,7 +16,7 @@
|
||||
<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">
|
||||
<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>
|
||||
<VBox fx:id="joueur1" alignment="CENTER" prefHeight="164.0" prefWidth="212.0" rotate="180.0">
|
||||
<children>
|
||||
|
@ -1,15 +1,34 @@
|
||||
package main;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import effet.Effet;
|
||||
|
||||
public class GestionnaireJeu {
|
||||
|
||||
|
||||
private Plateau plateau;
|
||||
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() {
|
||||
@ -20,11 +39,15 @@ public class GestionnaireJeu {
|
||||
this.plateau = plateau;
|
||||
}
|
||||
|
||||
public void lancerPartie(Configuration c) {
|
||||
//TODO
|
||||
public static void lancerPartie() {
|
||||
|
||||
}
|
||||
|
||||
public Configuration lancerConfiguration() {
|
||||
public void jouer(Configuration c) {
|
||||
|
||||
}
|
||||
|
||||
public static Configuration lancerConfiguration() {
|
||||
//TODO
|
||||
return null;
|
||||
}
|
||||
|
@ -1,5 +1,25 @@
|
||||
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