This commit is contained in:
Quentin Legot 2021-12-07 16:05:46 +01:00
commit 2a8eac9ea2

View File

@ -17,7 +17,9 @@ import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane; import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle; import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text; import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
import javafx.stage.Stage; import javafx.stage.Stage;
public class Window extends AbstractView { public class Window extends AbstractView {
@ -76,18 +78,14 @@ public class Window extends AbstractView {
} }
} }
putStatePlayerPane(principalPane); putStatePlayerPane(principalPane);
StackPane stateMoveTextPane = showMoveText(); putMoveTextPane(principalPane);
stateMoveTextPane.setLayoutY(480); Button buttonNext = new Button("SUIVANT");
principalPane.getChildren().add(stateMoveTextPane); buttonNext .setOnAction(new ClientEventHandler(new ButtonListener(game)));
buttonNext .setLayoutX(700);
buttonNext .setLayoutY(600);
Button followingButton = new Button("SUIVANT"); buttonNext .setStyle("-fx-background-color: #a96806;");
followingButton.setOnAction(new ClientEventHandler(new ButtonListener(game))); buttonNext .setTextFill(javafx.scene.paint.Color.WHITE);
followingButton.setLayoutX(700); principalPane.getChildren().add(buttonNext);
followingButton.setLayoutY(600);
followingButton.setStyle("-fx-background-color: #a96806;");
followingButton.setTextFill(javafx.scene.paint.Color.WHITE);
principalPane.getChildren().add(followingButton);
return principalPane; return principalPane;
} }
@ -99,12 +97,12 @@ public class Window extends AbstractView {
} }
// TODO: 07/12/2021 WARNING : générer autant de frames quil y a de joueurs,(à implémenter) // TODO: 07/12/2021 WARNING : générer autant de frames quil y a de joueurs,(à implémenter)
// TODO: 07/12/2021 Maintenant régler : Factorisation du code, Responsive // TODO: 07/12/2021 Maintenant régler : Responsive
//à voir si on peut faire plus proprement les deux méthodes en dessous avec une List<StackPane> ?
public void putStatePlayerPane(Pane principalPane){ public void putStatePlayerPane(Pane principalPane){
int Y = 0; int Y = 0;
for(int i=0;i < game.getPlayers().size();i++){ for(int i=0;i<game.getPlayers().size();i++){
StackPane sp = showStatePlayer(i); StackPane sp = showStatePlayer(i);
sp.setLayoutX(480); sp.setLayoutX(480);
sp.setLayoutY(Y); sp.setLayoutY(Y);
@ -119,22 +117,27 @@ public class Window extends AbstractView {
"Energie : " + game.getPlayers().get(playerNumber).getEnergy() + "\n" + "Energie : " + game.getPlayers().get(playerNumber).getEnergy() + "\n" +
"Arme : " + game.getPlayers().get(playerNumber).getWeapon().getClass().getSimpleName() + "\n"; "Arme : " + game.getPlayers().get(playerNumber).getWeapon().getClass().getSimpleName() + "\n";
Text t = new Text(s); Text t = new Text(s);
Rectangle r = new Rectangle(); Rectangle r = new Rectangle();
r.setWidth(500); r.setWidth(500);
r.setHeight(90); r.setHeight(90);
//à voir
if(game.getPlayers().get(playerNumber).getEnergy() <= 0){ if(game.getPlayers().get(playerNumber).getEnergy() <= 0){
r.setFill(Color.RED); r.setFill(Color.RED);
}else{ }else{
r.setFill(Color.GREEN); r.setFill(Color.GREEN);
} }
r.setStrokeWidth(2); r.setStrokeWidth(1);
r.setStroke(Color.BLACK); r.setStroke(Color.BLACK);
subSp.getChildren().addAll(r,t); subSp.getChildren().addAll(r,t);
return subSp; return subSp;
} }
//idem que au dessus public void putMoveTextPane(Pane principalPane){
StackPane stateMoveTextPane = showMoveText();
stateMoveTextPane.setLayoutY(480);
principalPane.getChildren().add((stateMoveTextPane));
}
public StackPane showMoveText(){ public StackPane showMoveText(){
StackPane subSp = new StackPane(); StackPane subSp = new StackPane();
String s = "Joueur : " + (player.getId()+1) + "\n" + String s = "Joueur : " + (player.getId()+1) + "\n" +
@ -143,7 +146,7 @@ public class Window extends AbstractView {
Rectangle r = new Rectangle(); Rectangle r = new Rectangle();
r.setWidth(478); r.setWidth(478);
r.setHeight(165); r.setHeight(165);
r.setStrokeWidth(2); r.setStrokeWidth(1);
r.setStroke(Color.BLACK); r.setStroke(Color.BLACK);
r.setFill(Color.WHITE); r.setFill(Color.WHITE);
subSp.getChildren().addAll(r,t); subSp.getChildren().addAll(r,t);