Scrolling area

This commit is contained in:
Paul Gross 2020-04-29 11:18:31 +02:00
parent 94e6c00001
commit 2c887d822e
12 changed files with 807 additions and 562 deletions

View File

@ -11,6 +11,7 @@ public class Main extends Application {
public void start(Stage primaryStage) throws Exception {
System.out.println("Lancement de l'application");
Pane root = FXMLLoader.load(getClass().getResource("ressources/PlateauTestPaul.fxml")); // "ressources/Jouer_tour(1)lancer_des.fxml"
primaryStage.show();

View File

@ -0,0 +1,37 @@
package ihm.controller;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.control.SplitPane;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
public class MenuJoueurController implements Initializable{
@Override
public void initialize(URL arg0, ResourceBundle arg1) {
//nomJoueur.setText(joueur.getNom());
}
@FXML
public void changeZoneToScrollPaneJoueur(MouseEvent me) throws IOException {
AnchorPane bp = FXMLLoader.load(getClass().getResource("../ressources/ScrollPaneJoueur.fxml"));
ImageView iv = ((ImageView)me.getSource());
Parent p = iv.getParent().getParent();
AnchorPane ap = (AnchorPane)p;
ap.getChildren().setAll(bp);
AnchorPane.setTopAnchor(bp, 0.0);
AnchorPane.setBottomAnchor(bp, 0.0);
AnchorPane.setLeftAnchor(bp, 0.0);
AnchorPane.setRightAnchor(bp, 0.0);
}
}

View File

@ -3,50 +3,28 @@ package ihm.controller;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import ihm.PopUp;
import ihm.PopUpBoolean;
import ihm.SpriteAnimation;
import javafx.animation.Animation;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.geometry.Rectangle2D;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import javafx.util.Duration;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import main.Joueur;
public class PlateauControllerTest implements Initializable {
private List<Joueur> listJoueur = new ArrayList<Joueur>();
private List<VBox> vboxJoueur = new ArrayList<VBox>();
private List<Button> btnRevelation = new ArrayList<Button>();
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 AnchorPane anchorPane1;
@FXML private AnchorPane anchorPane2;
@FXML private AnchorPane anchorPane3;
@FXML private AnchorPane anchorPane4;
@FXML private AnchorPane anchorPane5;
@FXML private AnchorPane anchorPane6;
@FXML private AnchorPane anchorPane7;
@FXML private AnchorPane anchorPane8;
@FXML private BorderPane root;
/**
* initialise les donn<EFBFBD>es du plateau
*/
@ -54,7 +32,77 @@ public class PlateauControllerTest implements Initializable {
public void initialize(URL arg0, ResourceBundle arg1) {
//initialisation des attributs des joueurs
for(int i = 0; i < 8; i++) {
AnchorPane ap = getAnchorPaneJoueur(i);
Pane p;
try {
p = FXMLLoader.load(getClass().getResource("../ressources/MenuJoueur.fxml"));
if(i > 1 && i < 3) {
rotateContent(p, 90);
}
setContentAnchorPane(ap, p);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public GridPane getGridPaneJoueur(int pos) {
int position = pos%8 / 2;
position++;
AnchorPane apParent = (AnchorPane) root.getChildren().get(position);
GridPane gp = (GridPane) apParent.getChildren().get(0);
return (GridPane) gp.getChildren().get(pos%2);
}
public AnchorPane getAnchorPaneJoueur(int pos) {
GridPane gp = getGridPaneJoueur(pos);
return (AnchorPane) gp.getChildren().get(0);
}
public ImageView getImageViewJoueur(int pos) {
GridPane gp = getGridPaneJoueur(pos);
return (ImageView) gp.getChildren().get(1);
}
public ScrollPane getScrollPaneJoueur(int pos) {
GridPane gp = getGridPaneJoueur(pos);
return (ScrollPane) gp.getChildren().get(2);
}
public void setContentAnchorPane(AnchorPane ap, Pane p) {
ap.getChildren().setAll(p);
AnchorPane.setTopAnchor(p, 0.0);
AnchorPane.setBottomAnchor(p, 0.0);
AnchorPane.setLeftAnchor(p, 0.0);
AnchorPane.setRightAnchor(p, 0.0);
}
public void rotateContent(Pane p, double rotation) {
p.setRotate(rotation);
}
/*
int OFFSET_X = 0;
int OFFSET_Y = 0;
int WIDTH = 557;
@ -95,25 +143,19 @@ public class PlateauControllerTest implements Initializable {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/
}
/**
* Affiche aux yeux de tous la carte personnage du joueur
*
* @param j : Le joueur sur lequel on a cliqu<EFBFBD>
*/
public void seReveler(int numJoueur) throws IOException {
System.out.println(listJoueur.get(numJoueur).getNom() + " se revele");
FXMLLoader loader = new FXMLLoader(getClass().getResource("../ressources/Reveler_son_identite.fxml"));
Parent root = loader.load();
RevelationController rc = loader.getController();
rc.showInformation(listJoueur.get(numJoueur));
PopUp popup = new PopUp(root, "Consulter sa carte");
popup.display();
}
public boolean choisir(Joueur j) throws IOException {
@ -135,27 +177,6 @@ public class PlateauControllerTest implements Initializable {
*
* @param j : Le joueur sur lequel on a cliqu<EFBFBD>
*/
public void consulterSaCarte(int numJoueur) throws IOException {
System.out.println(listJoueur.get(numJoueur).getNom() + " consulte sa carte");
FXMLLoader loader = new FXMLLoader(getClass().getResource("../ressources/afficher_carte_perso.fxml"));
Parent root = loader.load();
AfficherCarteController acc = loader.getController();
acc.showInformation(listJoueur.get(numJoueur));
PopUp popup = new PopUp(root, "Consulter sa carte");
popup.display();
}
public void showInformation(Map<Integer, Joueur> j) {
System.out.println("\tplacement des joueurs");
for (int i=0; i<this.vboxJoueur.size(); i++) {
if (j.get(i) != null)
nomJoueur.get(i).setText(j.get(i).getNom());
else {
vboxJoueur.get(i).setVisible(false);
}
}
}
}

View File

@ -15,8 +15,6 @@ 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;

View File

@ -0,0 +1,44 @@
package ihm.controller;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.control.SplitPane;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
public class ScrollPaneJoueurController implements Initializable{
@Override
public void initialize(URL arg0, ResourceBundle arg1) {
}
@FXML
public void changeZoneJoueurToMenuJoueur(MouseEvent me) throws IOException {
BorderPane bp = FXMLLoader.load(getClass().getResource("../ressources/MenuJoueur.fxml"));
ImageView iv = ((ImageView)me.getSource());
Parent p = iv.getParent().getParent().getParent().getParent();
AnchorPane ap = (AnchorPane)p;
System.out.println(bp.getRotate()+" "+ ap.getRotate());
ap.getChildren().setAll(bp);
AnchorPane.setTopAnchor(bp, 0.0);
AnchorPane.setBottomAnchor(bp, 0.0);
AnchorPane.setLeftAnchor(bp, 0.0);
AnchorPane.setRightAnchor(bp, 0.0);
}
}

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.BorderPane?>
<BorderPane prefHeight="200.0" prefWidth="200.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ihm.controller.MenuJoueurController">
<top>
<ImageView fitHeight="34.0" fitWidth="32.0" onMousePressed="#changeZoneToScrollPaneJoueur" pickOnBounds="true" preserveRatio="true" BorderPane.alignment="CENTER_RIGHT">
<image>
<Image url="@img/menuButton.png" />
</image>
</ImageView>
</top>
</BorderPane>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<AnchorPane xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ihm.controller.ScrollPaneJoueurController">
<children>
<SplitPane dividerPositions="0.298" prefHeight="155.0" prefWidth="368.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items>
<AnchorPane>
<children>
<ScrollPane hbarPolicy="NEVER" vbarPolicy="NEVER" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<AnchorPane>
<children>
<HBox spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<ImageView fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@img/dosCartesPersonnage.jpg" />
</image>
</ImageView>
<ImageView fitHeight="150.0" fitWidth="200.0" layoutX="10.0" layoutY="10.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@img/dosCartesPersonnage.jpg" />
</image>
</ImageView>
<ImageView fitHeight="150.0" fitWidth="200.0" layoutX="115.0" layoutY="10.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@img/dosCartesPersonnage.jpg" />
</image>
</ImageView>
<ImageView fitHeight="150.0" fitWidth="200.0" layoutX="219.0" layoutY="10.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@img/dosCartesPersonnage.jpg" />
</image>
</ImageView>
</children>
</HBox>
</children>
</AnchorPane>
</content>
</ScrollPane>
</children>
</AnchorPane>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity">
<children>
<ImageView fitHeight="30.0" focusTraversable="true" nodeOrientation="INHERIT" onMousePressed="#changeZoneJoueurToMenuJoueur" pickOnBounds="true" preserveRatio="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<image>
<Image url="@img/backButton.png" />
</image>
</ImageView>
</children>
</AnchorPane>
</items>
</SplitPane>
</children>
</AnchorPane>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.BorderPane?>
<BorderPane prefHeight="241.0" prefWidth="212.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<top>
<ImageView fitHeight="34.0" fitWidth="32.0" onMousePressed="#scrollPaneJoueurs" pickOnBounds="true" preserveRatio="true" BorderPane.alignment="CENTER">
<image>
<Image url="@img/menuButton.png" />
</image>
</ImageView>
</top>
</BorderPane>

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<ImageView fitHeight="33.0" fitWidth="200.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<image>
<Image url="@dice.sprite.png" />
</image>
</ImageView>

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB