From 09c4e875346baf68aa6390d6a46573c9f89f62c4 Mon Sep 17 00:00:00 2001 From: Mat Date: Sun, 30 Apr 2023 13:44:08 +0200 Subject: [PATCH] Clear CreateLevel1 to make a new class --- .../main/java/school_project/Controller.java | 49 +------------------ .../main/java/school_project/MenuAcceuil.java | 1 + .../java/school_project/MenuLevelDay1.java | 19 +++++++ 3 files changed, 21 insertions(+), 48 deletions(-) diff --git a/app/src/main/java/school_project/Controller.java b/app/src/main/java/school_project/Controller.java index 67028fc..1f8ad98 100644 --- a/app/src/main/java/school_project/Controller.java +++ b/app/src/main/java/school_project/Controller.java @@ -20,17 +20,10 @@ import javafx.stage.Stage; public class Controller extends Application { private Stage stage; //set up scene one - private Scene Menu; - private BorderPane BdP; - private Label title; - private Button Play; - private Button Select_level; - private Button Trophy; //set up scene 2 private Scene Level_menu; - private GridPane GdP; - private Button bck_menu; + //set up scene 3 private Scene Level_menu2; private GridPane GdP2; @@ -49,16 +42,6 @@ public class Controller extends Application { private Button Day_1; private Button Day_2; private Button Day_3; - private Button _1; - private Button _2; - private Button _3; - private Button _4; - private Button _5; - private Button _6; - private Button _7; - private Button _8; - private Button _9; - private Button _10; public void start(Stage primaryStage) { //set up the page @@ -73,37 +56,7 @@ public class Controller extends Application { } - private Scene createLevel_menu(){ - bck_menu = new Button("Back to the menu"); - bck_menu.setOnAction(event -> switchScenes(Menu)); - ColumnConstraints col_1 = new ColumnConstraints(); - col_1.setPercentWidth(33); - ColumnConstraints col_2 = new ColumnConstraints(); - col_2.setPercentWidth(33); - ColumnConstraints col_3 = new ColumnConstraints(); - col_3.setPercentWidth(34); - GdP.getColumnConstraints().addAll(col_1,col_2,col_3); - //GdP.setGridLinesVisible(true); - GridPane.setHalignment(_1, HPos.CENTER); - GridPane.setHalignment(_2, HPos.CENTER); - GridPane.setHalignment(_3, HPos.CENTER); - GridPane.setHalignment(_4, HPos.CENTER); - GridPane.setHalignment(_5, HPos.CENTER); - GridPane.setHalignment(_6, HPos.CENTER); - GridPane.setHalignment(_7, HPos.CENTER); - GridPane.setHalignment(_8, HPos.CENTER); - GridPane.setHalignment(_9, HPos.CENTER); - GridPane.setHalignment(_10, HPos.CENTER); - GridPane.setHalignment(Day_2, HPos.LEFT); - GridPane.setHalignment(Day_3, HPos.RIGHT); - GridPane.setHalignment(bck_menu, HPos.CENTER); - - Day_2.setOnAction(event -> switchScenes(Level_menu2)); - - - return Level_menu; - } private Scene createLevel_Menu2(){ bck_menu = new Button("Back to menu"); bck_menu.setOnAction(event -> switchScenes(Menu)); diff --git a/app/src/main/java/school_project/MenuAcceuil.java b/app/src/main/java/school_project/MenuAcceuil.java index 8f4f743..d93f68c 100644 --- a/app/src/main/java/school_project/MenuAcceuil.java +++ b/app/src/main/java/school_project/MenuAcceuil.java @@ -36,6 +36,7 @@ public class MenuAcceuil extends GridPane { BorderPane.setAlignment(Trophy,Pos.CENTER); //Menu.getStylesheets().add("style.css"); todo creat a file css BdP.setPadding(new Insets(20,60,20,60)); + //need help to add MenuAcceuil } diff --git a/app/src/main/java/school_project/MenuLevelDay1.java b/app/src/main/java/school_project/MenuLevelDay1.java index 00c7d52..cb111bf 100644 --- a/app/src/main/java/school_project/MenuLevelDay1.java +++ b/app/src/main/java/school_project/MenuLevelDay1.java @@ -20,6 +20,11 @@ public class MenuLevelDay1 extends GridPane { super(); GdP = new GridPane(); //add all the button for level + for (Button c : Level_button) { + c = new Button(); + } + + Level_button[0] = new Button("1"); Level_button[1] = new Button("2"); Level_button[2]= new Button("3"); @@ -48,6 +53,20 @@ public class MenuLevelDay1 extends GridPane { GdP.add(Level_button[9],1,4); GdP.add(Level_button[12],2,4); + for( int i= 0;i<=9;i++); + GridPane.setHalignment((Level_button[i],HPos.CENTER));; + + GridPane.setHalignment(Level_button[10], HPos.LEFT); + GridPane.setHalignment(Level_button[11], HPos.RIGHT); + GridPane.setHalignment(Level_button[12], HPos.CENTER); + ColumnConstraints col_1 = new ColumnConstraints(); + col_1.setPercentWidth(33); + ColumnConstraints col_2 = new ColumnConstraints(); + col_2.setPercentWidth(33); + ColumnConstraints col_3 = new ColumnConstraints(); + col_3.setPercentWidth(34); + GdP.getColumnConstraints().addAll(col_1,col_2,col_3); +