Modification de putStatePlayerPane(), showStatePlayer(),showMoveText() (Reste à corriger certaines choses)
This commit is contained in:
parent
bb44efd9fc
commit
1defc451aa
@ -7,22 +7,16 @@ import fr.lnl.game.server.games.grid.elements.*;
|
|||||||
import fr.lnl.game.server.games.player.Player;
|
import fr.lnl.game.server.games.player.Player;
|
||||||
import fr.lnl.game.server.utils.Pair;
|
import fr.lnl.game.server.utils.Pair;
|
||||||
import fr.lnl.game.server.utils.Point;
|
import fr.lnl.game.server.utils.Point;
|
||||||
import javafx.geometry.Pos;
|
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.shape.Rectangle;
|
import javafx.scene.shape.Rectangle;
|
||||||
import javafx.scene.text.Font;
|
|
||||||
import javafx.scene.text.FontPosture;
|
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import javafx.scene.text.TextAlignment;
|
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Window extends AbstractView {
|
public class Window extends AbstractView {
|
||||||
|
|
||||||
public static final int cellSize = 40;
|
public static final int cellSize = 40;
|
||||||
@ -39,7 +33,6 @@ public class Window extends AbstractView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void show() {
|
public void show() {
|
||||||
// stage.initModality(Modality.APPLICATION_MODAL);
|
|
||||||
Scene scene = new Scene(createContent());
|
Scene scene = new Scene(createContent());
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
stage.setTitle("Game");
|
stage.setTitle("Game");
|
||||||
@ -51,14 +44,12 @@ public class Window extends AbstractView {
|
|||||||
private Parent createContent() {
|
private Parent createContent() {
|
||||||
Pane principalPane = new Pane();
|
Pane principalPane = new Pane();
|
||||||
principalPane.setPrefSize(width * cellSize, height * cellSize); // TODO: 04/12/2021 A corriger -> doit plutôt s'adapter à la taille de la grid (grid.getRow() et grid.getColumn())
|
principalPane.setPrefSize(width * cellSize, height * cellSize); // TODO: 04/12/2021 A corriger -> doit plutôt s'adapter à la taille de la grid (grid.getRow() et grid.getColumn())
|
||||||
|
|
||||||
for (int i = 0; i < game.getGrid().getRow(); i++) {
|
for (int i = 0; i < game.getGrid().getRow(); i++) {
|
||||||
for (int j = 0; j < game.getGrid().getColumn(); j++) {
|
for (int j = 0; j < game.getGrid().getColumn(); j++) {
|
||||||
Cell cell = new Cell(i, j);
|
Cell cell = new Cell(i, j);
|
||||||
principalPane.getChildren().add(cell);
|
principalPane.getChildren().add(cell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Grid grid = game.getGrid();
|
Grid grid = game.getGrid();
|
||||||
for (int i = 0; i < grid.getRow(); i++) {
|
for (int i = 0; i < grid.getRow(); i++) {
|
||||||
for (int j = 0; j < grid.getColumn(); j++) {
|
for (int j = 0; j < grid.getColumn(); j++) {
|
||||||
@ -71,49 +62,82 @@ public class Window extends AbstractView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
putStatePlayerPane(principalPane);
|
||||||
|
StackPane stateMoveTextPane = showMoveText();
|
||||||
|
stateMoveTextPane.setLayoutY(480);
|
||||||
|
principalPane.getChildren().add(stateMoveTextPane);
|
||||||
|
|
||||||
|
|
||||||
StackPane sp = showStatePlayers();
|
|
||||||
sp.setLayoutX(480);
|
|
||||||
Button followingButton = new Button("SUIVANT");
|
Button followingButton = new Button("SUIVANT");
|
||||||
followingButton.setOnAction(new ClientEventHandler(new ButtonListener(game)));
|
followingButton.setOnAction(new ClientEventHandler(new ButtonListener(game)));
|
||||||
followingButton.setLayoutX(775);
|
followingButton.setLayoutX(700);
|
||||||
followingButton.setLayoutY(600);
|
followingButton.setLayoutY(600);
|
||||||
followingButton.setStyle("-fx-background-color: #a96806;");
|
followingButton.setStyle("-fx-background-color: #a96806;");
|
||||||
followingButton.setTextFill(javafx.scene.paint.Color.WHITE);
|
followingButton.setTextFill(javafx.scene.paint.Color.WHITE);
|
||||||
|
principalPane.getChildren().add(followingButton);
|
||||||
principalPane.getChildren().addAll(sp,followingButton);
|
|
||||||
return principalPane;
|
return principalPane;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pane addToPrincipalPanel(Object object, Pane principalPane, int i, int j) {
|
public void addToPrincipalPanel(Object object, Pane principalPane, int i, int j) {
|
||||||
StackPane sp = Cell.setImageObject(object);
|
StackPane sp = Cell.setImageObject(object);
|
||||||
sp.setLayoutY(i * cellSize);
|
sp.setLayoutY(i * cellSize);
|
||||||
sp.setLayoutX(j * cellSize);
|
sp.setLayoutX(j * cellSize);
|
||||||
principalPane.getChildren().add(sp);
|
principalPane.getChildren().add(sp);
|
||||||
//à passer en void
|
|
||||||
return principalPane;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String showMoveText(){
|
// TODO: 07/12/2021 WARNING : générer autant de frames qu’il y a de joueurs,(à implémenter)
|
||||||
return "";
|
// TODO: 07/12/2021 Maintenant régler : Factorisation du code, Responsive
|
||||||
}
|
|
||||||
|
|
||||||
public StackPane showStatePlayers(){
|
|
||||||
StackPane subSp = new StackPane();
|
|
||||||
|
|
||||||
|
//à voir si on peut faire plus proprement les deux méthodes en dessous avec une List<StackPane> ?
|
||||||
|
public void putStatePlayerPane(Pane principalPane){
|
||||||
|
int Y = 0;
|
||||||
for(int i=0;i < game.getPlayers().size();i++){
|
for(int i=0;i < game.getPlayers().size();i++){
|
||||||
String s = "Joueur " + i + "\n" +
|
StackPane sp = showStatePlayer(i);
|
||||||
"Energie : " + game.getPlayers().get(i).getEnergy() + "\n" +
|
sp.setLayoutX(480);
|
||||||
"Arme : " + "Aucune" /*game.getPlayers().get(i).getWeapon()*/ + "\n";
|
sp.setLayoutY(Y);
|
||||||
Text text = new Text(s);
|
Y+=90;
|
||||||
Rectangle rectangle = new Rectangle();
|
principalPane.getChildren().add(sp);
|
||||||
rectangle.setWidth(500 * i);
|
}
|
||||||
rectangle.setHeight(90 * i);
|
|
||||||
rectangle.setFill(javafx.scene.paint.Color.WHITE);
|
|
||||||
subSp.getChildren().addAll(rectangle,text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StackPane showStatePlayer(int playerNumber){
|
||||||
|
StackPane subSp = new StackPane();
|
||||||
|
String s = "Joueur " + (playerNumber+1) + "\n" +
|
||||||
|
"Energie : " + game.getPlayers().get(playerNumber).getEnergy() + "\n" +
|
||||||
|
"Arme : " + game.getPlayers().get(playerNumber).getWeapon() + "\n";
|
||||||
|
Text t = new Text(s);
|
||||||
|
Rectangle r = new Rectangle();
|
||||||
|
r.setWidth(500);
|
||||||
|
r.setHeight(90);
|
||||||
|
//à voir
|
||||||
|
if(game.getPlayers().get(playerNumber).getEnergy() <= 0){
|
||||||
|
r.setFill(Color.RED);
|
||||||
|
}else{
|
||||||
|
r.setFill(Color.GREEN);
|
||||||
|
}
|
||||||
|
r.setStrokeWidth(2);
|
||||||
|
r.setStroke(Color.BLACK);
|
||||||
|
subSp.getChildren().addAll(r,t);
|
||||||
return subSp;
|
return subSp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//idem que au dessus
|
||||||
|
public StackPane showMoveText(){
|
||||||
|
StackPane subSp = new StackPane();
|
||||||
|
String s = "Joueur : " + (player.getId()+1) + "\n" +
|
||||||
|
"Vient de jouer : " + game.getSelectedAction() + "\n";
|
||||||
|
Text t = new Text(s);
|
||||||
|
Rectangle r = new Rectangle();
|
||||||
|
r.setWidth(478);
|
||||||
|
r.setHeight(165);
|
||||||
|
r.setStrokeWidth(2);
|
||||||
|
r.setStroke(Color.BLACK);
|
||||||
|
r.setFill(Color.WHITE);
|
||||||
|
subSp.getChildren().addAll(r,t);
|
||||||
|
return subSp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user