Merge branch 'master' into 'buyAction'
# Conflicts: # src/main/java/latice/application/LaticeApplicationWindow.java # src/main/java/latice/model/Constant.javamaster
commit
e8ca530fab
|
@ -5,6 +5,9 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
|
import javafx.beans.binding.Bindings;
|
||||||
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.beans.property.StringProperty;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
|
@ -46,6 +49,7 @@ import latice.model.Tile;
|
||||||
import latice.model.console.Deck;
|
import latice.model.console.Deck;
|
||||||
import latice.model.console.Rack;
|
import latice.model.console.Rack;
|
||||||
import latice.model.console.Score;
|
import latice.model.console.Score;
|
||||||
|
import latice.model.window.PlayerFX;
|
||||||
import latice.model.window.RectangleFX;
|
import latice.model.window.RectangleFX;
|
||||||
|
|
||||||
public class LaticeApplicationWindow extends Application {
|
public class LaticeApplicationWindow extends Application {
|
||||||
|
@ -68,14 +72,14 @@ public class LaticeApplicationWindow extends Application {
|
||||||
|
|
||||||
|
|
||||||
//settings players
|
//settings players
|
||||||
public Player player1;
|
//public Player player1;
|
||||||
public Player player2;
|
//public Player player2;
|
||||||
|
|
||||||
//root layout
|
//borderPane layout
|
||||||
BorderPane root = new BorderPane();
|
public static BorderPane borderPane = new BorderPane();
|
||||||
|
|
||||||
//StackPane for background image + BorderPane root onto it
|
//StackPane for background image + BorderPane onto it
|
||||||
StackPane stackPane = new StackPane();
|
StackPane root = new StackPane();
|
||||||
|
|
||||||
static Stage primaryStageCopy;
|
static Stage primaryStageCopy;
|
||||||
StackPane parentStackPane = new StackPane();
|
StackPane parentStackPane = new StackPane();
|
||||||
|
@ -107,14 +111,14 @@ public class LaticeApplicationWindow extends Application {
|
||||||
moonErrorLabel.setFont(new Font(20));
|
moonErrorLabel.setFont(new Font(20));
|
||||||
moonErrorLabel.setTextFill(realColor.RED);
|
moonErrorLabel.setTextFill(realColor.RED);
|
||||||
topVbox.getChildren().add(moonErrorLabel);
|
topVbox.getChildren().add(moonErrorLabel);
|
||||||
root.setTop(topVbox);
|
borderPane.setTop(topVbox);
|
||||||
|
|
||||||
//Image
|
//Image
|
||||||
Pane pane = new Pane();
|
Pane pane = new Pane();
|
||||||
BackgroundImage myBG= new BackgroundImage(image,
|
BackgroundImage myBG= new BackgroundImage(image,
|
||||||
BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
|
BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
|
||||||
BackgroundSize.DEFAULT);
|
BackgroundSize.DEFAULT);
|
||||||
stackPane.setBackground(new Background(myBG));
|
root.setBackground(new Background(myBG));
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
//Creating rectangle for tiles placement
|
//Creating rectangle for tiles placement
|
||||||
|
@ -136,7 +140,7 @@ public class LaticeApplicationWindow extends Application {
|
||||||
counterI++;
|
counterI++;
|
||||||
}
|
}
|
||||||
|
|
||||||
root.setCenter(pane);
|
borderPane.setCenter(pane);
|
||||||
System.out.println(r);
|
System.out.println(r);
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -146,7 +150,7 @@ public class LaticeApplicationWindow extends Application {
|
||||||
for (Color color : Color.values()) {
|
for (Color color : Color.values()) {
|
||||||
for (Shape shape : Shape.values()) {
|
for (Shape shape : Shape.values()) {
|
||||||
Tile tile = new Tile(color, shape);
|
Tile tile = new Tile(color, shape);
|
||||||
System.out.println(color.getStringColor() + shape.getStringShape()+ ".png");
|
//System.out.println(color.getStringColor() + shape.getStringShape()+ ".png");
|
||||||
|
|
||||||
listOfTile.add(tile);
|
listOfTile.add(tile);
|
||||||
|
|
||||||
|
@ -158,12 +162,15 @@ public class LaticeApplicationWindow extends Application {
|
||||||
Deck deck2 = new Deck(listOfTile);
|
Deck deck2 = new Deck(listOfTile);
|
||||||
|
|
||||||
//setting player names
|
//setting player names
|
||||||
//String name1 = PlayerNameInputController.getNomJoueur1().getText();
|
StringProperty name1 = new SimpleStringProperty();
|
||||||
//String name2 = PlayerNameInputController.getNomJoueur2().getText();
|
StringProperty name2 = new SimpleStringProperty();
|
||||||
|
//name1.bind(PlayerNameInputController.namePlayer1);
|
||||||
|
//name2.bind(PlayerNameInputController.namePlayer2);
|
||||||
Player player1 = new Player(namePlayer1.getText(), new Score(), deck1, new Rack(deck1));
|
|
||||||
Player player2 = new Player(namePlayer2.getText(), new Score(), deck2, new Rack(deck2));
|
//Player player1 = new Player(namePlayer1.getText(), new Score(), deck1, new Rack(deck1));
|
||||||
|
//Player player2 = new Player(namePlayer2.getText(), new Score(), deck2, new Rack(deck2));
|
||||||
|
//Player player1 = MSC.instanciatePlayer(PlayerNameInputController.getNomJoueur1());
|
||||||
|
//Player player2 = MSC.instanciatePlayer(PlayerNameInputController.getNomJoueur2());
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
//Rack
|
//Rack
|
||||||
|
@ -416,8 +423,9 @@ public class LaticeApplicationWindow extends Application {
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
setPrimaryStage(primaryStage);
|
setPrimaryStage(primaryStage);
|
||||||
setRootLayout(stackPane);
|
|
||||||
stackPane.getChildren().addAll(players, root);
|
setRootLayout(root);
|
||||||
|
//root.getChildren().add(borderPane);
|
||||||
|
|
||||||
primaryStage.setResizable(false);
|
primaryStage.setResizable(false);
|
||||||
primaryStage.setTitle("Latice");
|
primaryStage.setTitle("Latice");
|
||||||
|
@ -428,6 +436,10 @@ public class LaticeApplicationWindow extends Application {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void setDragnDropOnRack(HBox rackImage) {
|
private void setDragnDropOnRack(HBox rackImage) {
|
||||||
//Setting drag n drop on tiles
|
//Setting drag n drop on tiles
|
||||||
for (int i=0; i<5; i++) {
|
for (int i=0; i<5; i++) {
|
||||||
|
@ -501,8 +513,8 @@ public class LaticeApplicationWindow extends Application {
|
||||||
|
|
||||||
public void transition(Label player1, Label player2) {
|
public void transition(Label player1, Label player2) {
|
||||||
|
|
||||||
root.setLeft(player1);
|
borderPane.setLeft(player1);
|
||||||
root.setRight(player2);
|
borderPane.setRight(player2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -16,6 +16,7 @@ import javafx.scene.Scene;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.layout.BorderPane;
|
import javafx.scene.layout.BorderPane;
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
import javafx.scene.shape.Rectangle;
|
import javafx.scene.shape.Rectangle;
|
||||||
import javafx.stage.Modality;
|
import javafx.stage.Modality;
|
||||||
|
@ -29,6 +30,7 @@ import latice.model.Tile;
|
||||||
import latice.model.console.Deck;
|
import latice.model.console.Deck;
|
||||||
import latice.model.console.Rack;
|
import latice.model.console.Rack;
|
||||||
import latice.model.console.Score;
|
import latice.model.console.Score;
|
||||||
|
import latice.model.window.PlayerFX;
|
||||||
|
|
||||||
public class MainScreenController extends LaticeApplicationWindow{
|
public class MainScreenController extends LaticeApplicationWindow{
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -45,9 +47,9 @@ public class MainScreenController extends LaticeApplicationWindow{
|
||||||
private static StackPane parentStackPaneStock;
|
private static StackPane parentStackPaneStock;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Player player1;
|
public Player player1;
|
||||||
public Player player2;
|
public Player player2;
|
||||||
|
public HBox players;
|
||||||
|
|
||||||
// Event Listener on Rectangle[#playButton].onMouseClicked
|
// Event Listener on Rectangle[#playButton].onMouseClicked
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -59,6 +61,7 @@ public class MainScreenController extends LaticeApplicationWindow{
|
||||||
System.out.println(mainStage);
|
System.out.println(mainStage);
|
||||||
if (!PlayerNameInputController.btnClicked) {
|
if (!PlayerNameInputController.btnClicked) {
|
||||||
playerNamesInput(event);
|
playerNamesInput(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,6 +136,9 @@ public class MainScreenController extends LaticeApplicationWindow{
|
||||||
System.out.println(parentStackPaneStock);
|
System.out.println(parentStackPaneStock);
|
||||||
parentStackPane.getChildren().add(root);
|
parentStackPane.getChildren().add(root);
|
||||||
|
|
||||||
|
players = PlayerFX.displayPlayers(parentStackPane,player1, player2);
|
||||||
|
root.getChildren().addAll(players,LaticeApplicationWindow.borderPane);
|
||||||
|
|
||||||
//parameters of the animation
|
//parameters of the animation
|
||||||
Timeline timeline = new Timeline();
|
Timeline timeline = new Timeline();
|
||||||
KeyValue kv = new KeyValue(root.translateYProperty(), 0, Interpolator.EASE_IN);
|
KeyValue kv = new KeyValue(root.translateYProperty(), 0, Interpolator.EASE_IN);
|
||||||
|
@ -154,6 +160,7 @@ public class MainScreenController extends LaticeApplicationWindow{
|
||||||
this.parentStackPane = parentStackPane;
|
this.parentStackPane = parentStackPane;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Player instanciatePlayer(String namePlayer) {
|
public Player instanciatePlayer(String namePlayer) {
|
||||||
//###################### Instantiating of players ######################///
|
//###################### Instantiating of players ######################///
|
||||||
//create the list of all tiles
|
//create the list of all tiles
|
||||||
|
@ -161,7 +168,7 @@ public class MainScreenController extends LaticeApplicationWindow{
|
||||||
for (Color color : Color.values()) {
|
for (Color color : Color.values()) {
|
||||||
for (Shape shape : Shape.values()) {
|
for (Shape shape : Shape.values()) {
|
||||||
Tile tile = new Tile(color, shape);
|
Tile tile = new Tile(color, shape);
|
||||||
System.out.println(color.getStringColor() + shape.getStringShape()+ ".png");
|
//System.out.println(color.getStringColor() + shape.getStringShape()+ ".png");
|
||||||
|
|
||||||
listOfTile.add(tile);
|
listOfTile.add(tile);
|
||||||
|
|
||||||
|
@ -174,4 +181,6 @@ public class MainScreenController extends LaticeApplicationWindow{
|
||||||
Player player = new Player(namePlayer, new Score(), deck, new Rack(deck));
|
Player player = new Player(namePlayer, new Score(), deck, new Rack(deck));
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package latice.controller;
|
package latice.controller;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.beans.property.StringProperty;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
|
@ -8,18 +12,29 @@ import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import latice.application.LaticeApplicationWindow;
|
import latice.application.LaticeApplicationWindow;
|
||||||
|
import latice.model.Color;
|
||||||
|
import latice.model.Player;
|
||||||
|
import latice.model.Shape;
|
||||||
|
import latice.model.Tile;
|
||||||
|
import latice.model.console.Deck;
|
||||||
|
import latice.model.console.Rack;
|
||||||
|
import latice.model.console.Score;
|
||||||
|
import latice.model.window.PlayerFX;
|
||||||
|
|
||||||
public class PlayerNameInputController {
|
public class PlayerNameInputController {
|
||||||
@FXML
|
@FXML
|
||||||
private TextField nomJoueur1;
|
public TextField nomJoueur1;
|
||||||
@FXML
|
@FXML
|
||||||
private TextField nomJoueur2;
|
public TextField nomJoueur2;
|
||||||
@FXML
|
@FXML
|
||||||
public Button btnValid;
|
public Button btnValid;
|
||||||
public static boolean btnClicked = false;
|
public static boolean btnClicked = false;
|
||||||
MainScreenController mainScreenController = new MainScreenController();
|
MainScreenController mainScreenController = new MainScreenController();
|
||||||
LaticeApplicationWindow laticeApplicationWindow = new LaticeApplicationWindow();
|
LaticeApplicationWindow laticeApplicationWindow = new LaticeApplicationWindow();
|
||||||
|
|
||||||
|
public static String namePlayer1;
|
||||||
|
public static String namePlayer2;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void validBtnClicked(MouseEvent event) {
|
public void validBtnClicked(MouseEvent event) {
|
||||||
System.out.println("valid Button Clicked");
|
System.out.println("valid Button Clicked");
|
||||||
|
@ -27,26 +42,32 @@ public class PlayerNameInputController {
|
||||||
//setting player names
|
//setting player names
|
||||||
String name1 = nomJoueur1.getText();
|
String name1 = nomJoueur1.getText();
|
||||||
String name2 = nomJoueur2.getText();
|
String name2 = nomJoueur2.getText();
|
||||||
|
System.out.println(nomJoueur1.getText());
|
||||||
|
System.out.println("nom des joueurs");
|
||||||
|
System.out.println(nomJoueur2.getText());
|
||||||
|
namePlayer1 = name1;
|
||||||
|
namePlayer2 = name2;
|
||||||
|
|
||||||
btnClicked = true;
|
btnClicked = true;
|
||||||
nameInputStage.close();
|
nameInputStage.close();
|
||||||
playerNamesEntered();
|
playerNamesEntered();
|
||||||
laticeApplicationWindow.player1 = mainScreenController.instanciatePlayer(name1);
|
mainScreenController.player1 = mainScreenController.instanciatePlayer(name1);
|
||||||
laticeApplicationWindow.player2 = mainScreenController.instanciatePlayer(name2);
|
mainScreenController.player2 = mainScreenController.instanciatePlayer(name2);
|
||||||
|
|
||||||
|
//PlayerFX.displayPlayers(root ,laticeApplicationWindow.player1, laticeApplicationWindow.player2);
|
||||||
mainScreenController.startGameInstruction();
|
mainScreenController.startGameInstruction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextField getNomJoueur1() {
|
public String getNomJoueur1() {
|
||||||
return nomJoueur1;
|
return nomJoueur1.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNomJoueur1(TextField nomJoueur1) {
|
public void setNomJoueur1(TextField nomJoueur1) {
|
||||||
this.nomJoueur1 = nomJoueur1;
|
this.nomJoueur1 = nomJoueur1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextField getNomJoueur2() {
|
public String getNomJoueur2() {
|
||||||
return nomJoueur2;
|
return nomJoueur2.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNomJoueur2(TextField nomJoueur2) {
|
public void setNomJoueur2(TextField nomJoueur2) {
|
||||||
|
@ -62,4 +83,5 @@ public class PlayerNameInputController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package latice.model.window;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import javafx.geometry.Insets;
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
|
import javafx.scene.layout.StackPane;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.scene.text.Font;
|
||||||
|
import javafx.scene.text.FontWeight;
|
||||||
|
import javafx.scene.text.Text;
|
||||||
|
import latice.model.Player;
|
||||||
|
|
||||||
|
public class PlayerFX {
|
||||||
|
|
||||||
|
|
||||||
|
public static HBox displayPlayers(StackPane root, Player player1, Player player2) {
|
||||||
|
//###################### display name, score and deck of each player ######################//
|
||||||
|
HBox players = new HBox();
|
||||||
|
|
||||||
|
ArrayList<Player> allPlayers = new ArrayList<>();
|
||||||
|
allPlayers.add(player1);
|
||||||
|
allPlayers.add(player2);
|
||||||
|
|
||||||
|
for (Player nameplayer : allPlayers ) {
|
||||||
|
VBox player = new VBox();
|
||||||
|
|
||||||
|
Text name = new Text();
|
||||||
|
name.setFont(Font.font(nameplayer.getName(), FontWeight.BOLD, 20));
|
||||||
|
name.setText(nameplayer.getName());
|
||||||
|
|
||||||
|
Text score = new Text();
|
||||||
|
score.setText("Score : ");
|
||||||
|
|
||||||
|
Text nbrOfTiles = new Text();
|
||||||
|
nbrOfTiles.setText("Tuiles restantes : ");
|
||||||
|
|
||||||
|
player.getChildren().addAll(name, score, nbrOfTiles);
|
||||||
|
player.setSpacing(5);
|
||||||
|
|
||||||
|
players.getChildren().add(player);
|
||||||
|
players.setMargin(player, new Insets(50,0,0,55));
|
||||||
|
}
|
||||||
|
System.out.println("largeur : " + root.getMaxWidth());
|
||||||
|
players.setSpacing(850);
|
||||||
|
return players;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue