From de4460e92c48e46ce2fccbdd1b052b7a884d928a Mon Sep 17 00:00:00 2001 From: Mathis Date: Wed, 1 Jun 2022 20:27:51 +0200 Subject: [PATCH] bugfix LaticeApplicationWindow | ADD Constant --- .../application/LaticeApplicationWindow.java | 50 +++++++++++++++++-- src/main/java/latice/model/Constant.java | 19 +++++++ 2 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 src/main/java/latice/model/Constant.java diff --git a/src/main/java/latice/application/LaticeApplicationWindow.java b/src/main/java/latice/application/LaticeApplicationWindow.java index 6258652..6c7aee6 100644 --- a/src/main/java/latice/application/LaticeApplicationWindow.java +++ b/src/main/java/latice/application/LaticeApplicationWindow.java @@ -274,12 +274,33 @@ public class LaticeApplicationWindow extends Application { //------------------------------------------------------------------------ //###################### creating all rectangles and DragnDrop ######################// - RectangleFX rectFX = new RectangleFX(); - rectFX.createRectangle(root, pane); - rectFX.dragnDropOnAllRectangles(player1, indexTileClicked, validateBtnClickedCount); - rectFX.dragnDropOnAllRectangles(player2, indexTileClicked, validateBtnClickedCount); + //ectangleFX rectFX = new RectangleFX(); + //rectFX.createRectangle(root, pane); + //rectFX.dragnDropOnAllRectangles(player1, indexTileClicked, validateBtnClickedCount); + //rectFX.dragnDropOnAllRectangles(player2, indexTileClicked, validateBtnClickedCount); //------------------------------------------------------------------------ + //Setting drag & drop on rectangles + for(int i=0; i() { + + @Override + public void handle(DragEvent arg0) { + if (arg0.getDragboard().hasString()){ + Dragboard dragboard = arg0.getDragboard(); + + r[a][b].setFill(new ImagePattern(listTileImage.get(getIndexTileClicked()))); + } + arg0.consume(); + } + }); + + r[a][b].setOnDragExited(new EventHandler() { + @Override public void handle(DragEvent arg0) { if (arg0.isDropCompleted() == false) { @@ -332,6 +353,25 @@ public class LaticeApplicationWindow extends Application { }); + } + } + + + //rules / referee implementaion + + this.transition(namePlayer1, namePlayer2); + //root.setLeft(namePlayer1); + + //###################### display name, score and deck of each player ######################// + HBox players = new HBox(); + + ArrayList 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()); @@ -349,7 +389,7 @@ public class LaticeApplicationWindow extends Application { players.setMargin(player, new Insets(50,0,0,55)); } System.out.println("largeur : " + root.getMaxWidth()); - players.setSpacing(850); + players.setSpacing(850); diff --git a/src/main/java/latice/model/Constant.java b/src/main/java/latice/model/Constant.java new file mode 100644 index 0000000..080c92f --- /dev/null +++ b/src/main/java/latice/model/Constant.java @@ -0,0 +1,19 @@ +package latice.model; + +public class Constant { + + //for creating rectangles + public static final int NUMBER_OF_BOX_ON_ONE_LINE = 9; + + public static final int RECTANGLE_HEIGHT = 50; + + public static final int RECTANGLE_WIDTH = 50; + + public static final int Y_CENTER = 37; + + public static final int X_CENTER = 355; + + public static final int BOX_WIDTH = 52; + + +}