diff --git a/app/src/main/java/school_project/Controller.java b/app/src/main/java/school_project/Controller.java index 62046bf..c37cf41 100644 --- a/app/src/main/java/school_project/Controller.java +++ b/app/src/main/java/school_project/Controller.java @@ -34,7 +34,7 @@ public class Controller extends Application { stage.setScene(new Scene(root)); } public static void main(String[] args) { - launch(args); + launch(); } } diff --git a/app/src/main/java/school_project/Menu/MenuAcceuil.java b/app/src/main/java/school_project/Menu/MenuAcceuil.java index 3883bc1..9bb5bf4 100644 --- a/app/src/main/java/school_project/Menu/MenuAcceuil.java +++ b/app/src/main/java/school_project/Menu/MenuAcceuil.java @@ -8,18 +8,16 @@ import javafx.scene.paint.Color; import javafx.scene.text.Font; import school_project.Controller; public class MenuAcceuil extends BorderPane { - private Button Play; - public static Button SelectLevel; - private Button Trophy; - private Label Title; public MenuAcceuil(){ super(); - Play = new Button("Play"); - SelectLevel= new Button("Select Level"); - Trophy = new Button("Trophy"); - Title = new Label("Welcome to Road to Master"); + //create all the objet that i need + Button Play = new Button("Play"); + Button SelectLevel= new Button("Select Level"); + Button Trophy = new Button("Trophy"); + Label Title = new Label("Welcome to Road to Master"); + //set up all the Button where i need setTop(Title); setLeft(Play); setRight(SelectLevel); @@ -30,7 +28,6 @@ public class MenuAcceuil extends BorderPane { setAlignment(Play,Pos.CENTER); setAlignment(SelectLevel,Pos.CENTER); setAlignment(Trophy,Pos.CENTER); - //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"); diff --git a/app/src/main/java/school_project/Menu/MenuLevel.java b/app/src/main/java/school_project/Menu/MenuLevel.java index a02cef4..f86f699 100644 --- a/app/src/main/java/school_project/Menu/MenuLevel.java +++ b/app/src/main/java/school_project/Menu/MenuLevel.java @@ -9,20 +9,26 @@ import javafx.scene.layout.RowConstraints; import school_project.Controller; public class MenuLevel extends GridPane { - public Button BckMenu; - public Button[] Days = new Button[3]; - public int StartLevel; - public ColumnConstraints[] Columns = new ColumnConstraints[3]; - public RowConstraints[] Rows = new RowConstraints[5]; - + private int StartLevel; public MenuLevel(int choose_day) { - BckMenu = new Button("Back to menu"); + + //create all Object that I need + RowConstraints[] Rows = new RowConstraints[5]; + ColumnConstraints[] Columns = new ColumnConstraints[3]; + Button[] Days = new Button[3]; + Button 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)); } + + //it's here that I know which day I can show on the screen + if (choose_day == 1) { StartLevel = 1; add(Days[1],0,0); @@ -30,6 +36,7 @@ public class MenuLevel extends GridPane { setHalignment(Days[1], HPos.CENTER); setHalignment(Days[2], HPos.CENTER); } + else if (choose_day == 2) { StartLevel = 11; add(Days[0], 0, 0); @@ -37,6 +44,7 @@ public class MenuLevel extends GridPane { setHalignment(Days[0], HPos.CENTER); setHalignment(Days[2], HPos.CENTER); } + else if (choose_day == 3) { StartLevel = 21; add(Days[0], 0, 0); @@ -44,10 +52,12 @@ public class MenuLevel extends GridPane { setHalignment(Days[0], HPos.CENTER); setHalignment(Days[1], HPos.CENTER); } + Days[0].setOnAction(event -> Controller.switchRoot(new MenuLevel(1))); Days[1].setOnAction(event -> Controller.switchRoot(new MenuLevel(2))); Days[2].setOnAction(event -> Controller.switchRoot(new MenuLevel(3))); + //It's here that I put all buttons where I need (base on column not row) for (int i = 0; i < 3; i++) { for (int j = 1; j < 5; j++) { if(i==0){ @@ -77,28 +87,24 @@ public class MenuLevel extends GridPane { } } } + for(int i=0;i<=2;i++){ Columns[i] = new ColumnConstraints(); Columns[i].setPercentWidth(33); getColumnConstraints().addAll(Columns[i]); } + for (int i= 0;i<=4;i++){ Rows[i] = new RowConstraints(); Rows[i].setPercentHeight(20); getRowConstraints().addAll(Rows[i]); } + setHgap(20); setVgap(20); setPadding(new Insets(20,10,10,20)); getStyleClass().add("GridPane"); getStylesheets().add(String.valueOf(getClass().getResource("StyleMenuAcceuil.css"))); - - - - - - - } }