Merge branch 'master' into 'buyAction'

# Conflicts:
#   src/main/java/latice/application/LaticeApplicationWindow.java
#   src/main/java/latice/model/Constant.java
master
Odabasioglu Cemal 2022-06-02 06:34:18 +00:00
commit e8ca530fab
4 changed files with 123 additions and 31 deletions

View File

@ -5,6 +5,9 @@ import java.util.HashMap;
import java.util.Map;
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.fxml.FXMLLoader;
import javafx.geometry.Insets;
@ -46,6 +49,7 @@ import latice.model.Tile;
import latice.model.console.Deck;
import latice.model.console.Rack;
import latice.model.console.Score;
import latice.model.window.PlayerFX;
import latice.model.window.RectangleFX;
public class LaticeApplicationWindow extends Application {
@ -68,14 +72,14 @@ public class LaticeApplicationWindow extends Application {
//settings players
public Player player1;
public Player player2;
//public Player player1;
//public Player player2;
//root layout
BorderPane root = new BorderPane();
//borderPane layout
public static BorderPane borderPane = new BorderPane();
//StackPane for background image + BorderPane root onto it
StackPane stackPane = new StackPane();
//StackPane for background image + BorderPane onto it
StackPane root = new StackPane();
static Stage primaryStageCopy;
StackPane parentStackPane = new StackPane();
@ -107,14 +111,14 @@ public class LaticeApplicationWindow extends Application {
moonErrorLabel.setFont(new Font(20));
moonErrorLabel.setTextFill(realColor.RED);
topVbox.getChildren().add(moonErrorLabel);
root.setTop(topVbox);
borderPane.setTop(topVbox);
//Image
Pane pane = new Pane();
BackgroundImage myBG= new BackgroundImage(image,
BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
BackgroundSize.DEFAULT);
stackPane.setBackground(new Background(myBG));
root.setBackground(new Background(myBG));
//--------------------------------------------------------------------------------------
//Creating rectangle for tiles placement
@ -136,7 +140,7 @@ public class LaticeApplicationWindow extends Application {
counterI++;
}
root.setCenter(pane);
borderPane.setCenter(pane);
System.out.println(r);
//--------------------------------------------------------------------------------------
@ -146,7 +150,7 @@ public class LaticeApplicationWindow extends Application {
for (Color color : Color.values()) {
for (Shape shape : Shape.values()) {
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);
@ -158,12 +162,15 @@ public class LaticeApplicationWindow extends Application {
Deck deck2 = new Deck(listOfTile);
//setting player names
//String name1 = PlayerNameInputController.getNomJoueur1().getText();
//String name2 = PlayerNameInputController.getNomJoueur2().getText();
Player player1 = new Player(namePlayer1.getText(), new Score(), deck1, new Rack(deck1));
Player player2 = new Player(namePlayer2.getText(), new Score(), deck2, new Rack(deck2));
StringProperty name1 = new SimpleStringProperty();
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 = MSC.instanciatePlayer(PlayerNameInputController.getNomJoueur1());
//Player player2 = MSC.instanciatePlayer(PlayerNameInputController.getNomJoueur2());
//--------------------------------------------------------------------------------------
//Rack
@ -416,8 +423,9 @@ public class LaticeApplicationWindow extends Application {
//--------------------------------------------------------------------------------------
setPrimaryStage(primaryStage);
setRootLayout(stackPane);
stackPane.getChildren().addAll(players, root);
setRootLayout(root);
//root.getChildren().add(borderPane);
primaryStage.setResizable(false);
primaryStage.setTitle("Latice");
@ -428,6 +436,10 @@ public class LaticeApplicationWindow extends Application {
private void setDragnDropOnRack(HBox rackImage) {
//Setting drag n drop on tiles
for (int i=0; i<5; i++) {
@ -501,8 +513,8 @@ public class LaticeApplicationWindow extends Application {
public void transition(Label player1, Label player2) {
root.setLeft(player1);
root.setRight(player2);
borderPane.setLeft(player1);
borderPane.setRight(player2);
}
}

View File

@ -16,6 +16,7 @@ import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.shape.Rectangle;
import javafx.stage.Modality;
@ -29,6 +30,7 @@ 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 MainScreenController extends LaticeApplicationWindow{
@FXML
@ -45,9 +47,9 @@ public class MainScreenController extends LaticeApplicationWindow{
private static StackPane parentStackPaneStock;
public Player player1;
public Player player2;
public HBox players;
// Event Listener on Rectangle[#playButton].onMouseClicked
@FXML
@ -59,6 +61,7 @@ public class MainScreenController extends LaticeApplicationWindow{
System.out.println(mainStage);
if (!PlayerNameInputController.btnClicked) {
playerNamesInput(event);
}
}
@ -133,6 +136,9 @@ public class MainScreenController extends LaticeApplicationWindow{
System.out.println(parentStackPaneStock);
parentStackPane.getChildren().add(root);
players = PlayerFX.displayPlayers(parentStackPane,player1, player2);
root.getChildren().addAll(players,LaticeApplicationWindow.borderPane);
//parameters of the animation
Timeline timeline = new Timeline();
KeyValue kv = new KeyValue(root.translateYProperty(), 0, Interpolator.EASE_IN);
@ -154,6 +160,7 @@ public class MainScreenController extends LaticeApplicationWindow{
this.parentStackPane = parentStackPane;
}
public Player instanciatePlayer(String namePlayer) {
//###################### Instantiating of players ######################///
//create the list of all tiles
@ -161,7 +168,7 @@ public class MainScreenController extends LaticeApplicationWindow{
for (Color color : Color.values()) {
for (Shape shape : Shape.values()) {
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);
@ -174,4 +181,6 @@ public class MainScreenController extends LaticeApplicationWindow{
Player player = new Player(namePlayer, new Score(), deck, new Rack(deck));
return player;
}
}

View File

@ -1,5 +1,9 @@
package latice.controller;
import java.util.ArrayList;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Button;
@ -8,18 +12,29 @@ import javafx.scene.input.MouseEvent;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
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 {
@FXML
private TextField nomJoueur1;
public TextField nomJoueur1;
@FXML
private TextField nomJoueur2;
public TextField nomJoueur2;
@FXML
public Button btnValid;
public static boolean btnClicked = false;
MainScreenController mainScreenController = new MainScreenController();
LaticeApplicationWindow laticeApplicationWindow = new LaticeApplicationWindow();
public static String namePlayer1;
public static String namePlayer2;
@FXML
public void validBtnClicked(MouseEvent event) {
System.out.println("valid Button Clicked");
@ -27,26 +42,32 @@ public class PlayerNameInputController {
//setting player names
String name1 = nomJoueur1.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;
nameInputStage.close();
playerNamesEntered();
laticeApplicationWindow.player1 = mainScreenController.instanciatePlayer(name1);
laticeApplicationWindow.player2 = mainScreenController.instanciatePlayer(name2);
mainScreenController.player1 = mainScreenController.instanciatePlayer(name1);
mainScreenController.player2 = mainScreenController.instanciatePlayer(name2);
//PlayerFX.displayPlayers(root ,laticeApplicationWindow.player1, laticeApplicationWindow.player2);
mainScreenController.startGameInstruction();
}
public TextField getNomJoueur1() {
return nomJoueur1;
public String getNomJoueur1() {
return nomJoueur1.getText();
}
public void setNomJoueur1(TextField nomJoueur1) {
this.nomJoueur1 = nomJoueur1;
}
public TextField getNomJoueur2() {
return nomJoueur2;
public String getNomJoueur2() {
return nomJoueur2.getText();
}
public void setNomJoueur2(TextField nomJoueur2) {
@ -62,4 +83,5 @@ public class PlayerNameInputController {
}
}

View File

@ -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;
}
}