From a3ad448fba79d16030345766cea2917109c3104e Mon Sep 17 00:00:00 2001 From: Mat Date: Fri, 5 May 2023 11:50:17 +0200 Subject: [PATCH] Finally finish the menu --- .../main/java/school_project/Controller.java | 7 +- .../java/school_project/Menu/MenuAcceuil.java | 3 + .../java/school_project/Menu/MenuLevel.java | 11 ++- .../school_project/Menu/MenuLevelDay1.java | 83 ------------------- .../school_project/Menu/StyleMenuAcceuil.css | 8 ++ 5 files changed, 21 insertions(+), 91 deletions(-) delete mode 100644 app/src/main/java/school_project/Menu/MenuLevelDay1.java create mode 100644 app/src/main/resources/school_project/Menu/StyleMenuAcceuil.css diff --git a/app/src/main/java/school_project/Controller.java b/app/src/main/java/school_project/Controller.java index 2112e8b..62046bf 100644 --- a/app/src/main/java/school_project/Controller.java +++ b/app/src/main/java/school_project/Controller.java @@ -7,8 +7,7 @@ import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; -import school_project.Menu.MenuAcceuil; -import school_project.Menu.MenuLevel; +import school_project.Menu.*; @@ -24,12 +23,10 @@ public class Controller extends Application { root = new MenuAcceuil(); stage = primaryStage; - stage.setTitle("ROAD TO MASTER YOU"); + stage.setTitle("ROAD TO MASTER"); stage.setScene(new Scene(root)); stage.show(); - - } diff --git a/app/src/main/java/school_project/Menu/MenuAcceuil.java b/app/src/main/java/school_project/Menu/MenuAcceuil.java index 39604d7..3883bc1 100644 --- a/app/src/main/java/school_project/Menu/MenuAcceuil.java +++ b/app/src/main/java/school_project/Menu/MenuAcceuil.java @@ -33,6 +33,9 @@ public class MenuAcceuil extends BorderPane { //Menu.getStylesheets().add("style.css"); todo creat a file css setPadding(new Insets(20,60,20,60)); SelectLevel.setOnAction(event -> Controller.switchRoot(new MenuLevel(1))); + getStyleClass().add("BorderPane"); + getStylesheets().add(String.valueOf(getClass().getResource("StyleMenuAcceuil.css"))); + } diff --git a/app/src/main/java/school_project/Menu/MenuLevel.java b/app/src/main/java/school_project/Menu/MenuLevel.java index cdd3624..a02cef4 100644 --- a/app/src/main/java/school_project/Menu/MenuLevel.java +++ b/app/src/main/java/school_project/Menu/MenuLevel.java @@ -18,6 +18,7 @@ public class MenuLevel extends GridPane { public MenuLevel(int choose_day) { BckMenu = new Button("Back to menu"); BckMenu.setOnAction(event -> Controller.switchRoot(new MenuAcceuil())); + setHalignment(BckMenu,HPos.CENTER); add(BckMenu,2,4); for (int i = 0; i < Days.length; i++){ Days[i] = new Button("Day"+(i+1)); @@ -78,7 +79,7 @@ public class MenuLevel extends GridPane { } for(int i=0;i<=2;i++){ Columns[i] = new ColumnConstraints(); - Columns[i].setPercentWidth(30); + Columns[i].setPercentWidth(33); getColumnConstraints().addAll(Columns[i]); } for (int i= 0;i<=4;i++){ @@ -89,8 +90,12 @@ public class MenuLevel extends GridPane { setHgap(20); setVgap(20); setPadding(new Insets(20,10,10,20)); - setGridLinesVisible(true); - alignmentProperty(); + getStyleClass().add("GridPane"); + getStylesheets().add(String.valueOf(getClass().getResource("StyleMenuAcceuil.css"))); + + + + diff --git a/app/src/main/java/school_project/Menu/MenuLevelDay1.java b/app/src/main/java/school_project/Menu/MenuLevelDay1.java deleted file mode 100644 index 1224db7..0000000 --- a/app/src/main/java/school_project/Menu/MenuLevelDay1.java +++ /dev/null @@ -1,83 +0,0 @@ -package school_project.Menu; - -import javafx.geometry.HPos; -import javafx.geometry.Insets; -import javafx.scene.Node; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.scene.control.Button; -import javafx.scene.layout.ColumnConstraints; -import javafx.scene.layout.GridPane; - -import java.util.HashMap; -import java.util.Map; - -public class MenuLevelDay1 extends GridPane { - //set up all object for the scene - public static Button[] Level_button = new Button[13]; - //set up the scene - private Scene Level_menu; - private GridPane GdP; - - public MenuLevelDay1 (){ - super(); - GdP = new GridPane(); - //add all the button for level - HashMap LevelButton = new HashMap(); - - /*for (Map.Entry c : LevelButton) { - c.setValue(new Button()); - required: array or java.lang.Iterable - found: HashMap - }*/ - - Level_button[0] = new Button("1"); - Level_button[1] = new Button("2"); - Level_button[2]= new Button("3"); - Level_button[3]= new Button("4"); - Level_button[6] = new Button("7"); - Level_button[7] = new Button("8"); - Level_button[8] = new Button("9"); - Level_button[9] = new Button("10"); - Level_button[10] = new Button("Day 2"); - Level_button[11] = new Button("Day 3"); - Level_button[12] = new Button("Back to menu"); - Level_button[4] = new Button("5"); - Level_button[5]= new Button("6"); - //add to the good position in gridpane all the button - GdP.add(Level_button[10],1,0); - GdP.add(Level_button[11],1,0); - GdP.add(Level_button[0],0,1); - GdP.add(Level_button[1],1,1); - GdP.add(Level_button[2],2,1); - GdP.add(Level_button[3],0,2); - GdP.add(Level_button[4],1,2); - GdP.add(Level_button[5],2,2); - GdP.add(Level_button[6],0,3); - GdP.add(Level_button[7],1,3); - GdP.add(Level_button[8],2,3); - 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));; - //todo understand why it doesn't work**/ - - 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); - - - - - - } - -} diff --git a/app/src/main/resources/school_project/Menu/StyleMenuAcceuil.css b/app/src/main/resources/school_project/Menu/StyleMenuAcceuil.css new file mode 100644 index 0000000..1fb30c0 --- /dev/null +++ b/app/src/main/resources/school_project/Menu/StyleMenuAcceuil.css @@ -0,0 +1,8 @@ +.BorderPane{ + -fx-background-image: url("BackGround-menu.jpg"); + -fx-background-position:center; +} +.GridPane{ + -fx-background-image: url("Background-select-level.jpg"); + -fx-background-position:right; +} \ No newline at end of file