Correct all thing say expect the one about switchRoot I didn't understand (Btw add some comment)
This commit is contained in:
parent
1af5db700e
commit
a043cb487f
@ -34,7 +34,7 @@ public class Controller extends Application {
|
|||||||
stage.setScene(new Scene(root));
|
stage.setScene(new Scene(root));
|
||||||
}
|
}
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
launch(args);
|
launch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,18 +8,16 @@ import javafx.scene.paint.Color;
|
|||||||
import javafx.scene.text.Font;
|
import javafx.scene.text.Font;
|
||||||
import school_project.Controller;
|
import school_project.Controller;
|
||||||
public class MenuAcceuil extends BorderPane {
|
public class MenuAcceuil extends BorderPane {
|
||||||
private Button Play;
|
|
||||||
public static Button SelectLevel;
|
|
||||||
private Button Trophy;
|
|
||||||
private Label Title;
|
|
||||||
|
|
||||||
|
|
||||||
public MenuAcceuil(){
|
public MenuAcceuil(){
|
||||||
super();
|
super();
|
||||||
Play = new Button("Play");
|
//create all the objet that i need
|
||||||
SelectLevel= new Button("Select Level");
|
Button Play = new Button("Play");
|
||||||
Trophy = new Button("Trophy");
|
Button SelectLevel= new Button("Select Level");
|
||||||
Title = new Label("Welcome to Road to Master");
|
Button Trophy = new Button("Trophy");
|
||||||
|
Label Title = new Label("Welcome to Road to Master");
|
||||||
|
//set up all the Button where i need
|
||||||
setTop(Title);
|
setTop(Title);
|
||||||
setLeft(Play);
|
setLeft(Play);
|
||||||
setRight(SelectLevel);
|
setRight(SelectLevel);
|
||||||
@ -30,7 +28,6 @@ public class MenuAcceuil extends BorderPane {
|
|||||||
setAlignment(Play,Pos.CENTER);
|
setAlignment(Play,Pos.CENTER);
|
||||||
setAlignment(SelectLevel,Pos.CENTER);
|
setAlignment(SelectLevel,Pos.CENTER);
|
||||||
setAlignment(Trophy,Pos.CENTER);
|
setAlignment(Trophy,Pos.CENTER);
|
||||||
//Menu.getStylesheets().add("style.css"); todo creat a file css
|
|
||||||
setPadding(new Insets(20,60,20,60));
|
setPadding(new Insets(20,60,20,60));
|
||||||
SelectLevel.setOnAction(event -> Controller.switchRoot(new MenuLevel(1)));
|
SelectLevel.setOnAction(event -> Controller.switchRoot(new MenuLevel(1)));
|
||||||
getStyleClass().add("BorderPane");
|
getStyleClass().add("BorderPane");
|
||||||
|
@ -9,20 +9,26 @@ import javafx.scene.layout.RowConstraints;
|
|||||||
import school_project.Controller;
|
import school_project.Controller;
|
||||||
|
|
||||||
public class MenuLevel extends GridPane {
|
public class MenuLevel extends GridPane {
|
||||||
public Button BckMenu;
|
private int StartLevel;
|
||||||
public Button[] Days = new Button[3];
|
|
||||||
public int StartLevel;
|
|
||||||
public ColumnConstraints[] Columns = new ColumnConstraints[3];
|
|
||||||
public RowConstraints[] Rows = new RowConstraints[5];
|
|
||||||
|
|
||||||
public MenuLevel(int choose_day) {
|
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()));
|
BckMenu.setOnAction(event -> Controller.switchRoot(new MenuAcceuil()));
|
||||||
setHalignment(BckMenu,HPos.CENTER);
|
setHalignment(BckMenu,HPos.CENTER);
|
||||||
add(BckMenu,2,4);
|
add(BckMenu,2,4);
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < Days.length; i++){
|
for (int i = 0; i < Days.length; i++){
|
||||||
Days[i] = new Button("Day"+(i+1));
|
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) {
|
if (choose_day == 1) {
|
||||||
StartLevel = 1;
|
StartLevel = 1;
|
||||||
add(Days[1],0,0);
|
add(Days[1],0,0);
|
||||||
@ -30,6 +36,7 @@ public class MenuLevel extends GridPane {
|
|||||||
setHalignment(Days[1], HPos.CENTER);
|
setHalignment(Days[1], HPos.CENTER);
|
||||||
setHalignment(Days[2], HPos.CENTER);
|
setHalignment(Days[2], HPos.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (choose_day == 2) {
|
else if (choose_day == 2) {
|
||||||
StartLevel = 11;
|
StartLevel = 11;
|
||||||
add(Days[0], 0, 0);
|
add(Days[0], 0, 0);
|
||||||
@ -37,6 +44,7 @@ public class MenuLevel extends GridPane {
|
|||||||
setHalignment(Days[0], HPos.CENTER);
|
setHalignment(Days[0], HPos.CENTER);
|
||||||
setHalignment(Days[2], HPos.CENTER);
|
setHalignment(Days[2], HPos.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (choose_day == 3) {
|
else if (choose_day == 3) {
|
||||||
StartLevel = 21;
|
StartLevel = 21;
|
||||||
add(Days[0], 0, 0);
|
add(Days[0], 0, 0);
|
||||||
@ -44,10 +52,12 @@ public class MenuLevel extends GridPane {
|
|||||||
setHalignment(Days[0], HPos.CENTER);
|
setHalignment(Days[0], HPos.CENTER);
|
||||||
setHalignment(Days[1], HPos.CENTER);
|
setHalignment(Days[1], HPos.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
Days[0].setOnAction(event -> Controller.switchRoot(new MenuLevel(1)));
|
Days[0].setOnAction(event -> Controller.switchRoot(new MenuLevel(1)));
|
||||||
Days[1].setOnAction(event -> Controller.switchRoot(new MenuLevel(2)));
|
Days[1].setOnAction(event -> Controller.switchRoot(new MenuLevel(2)));
|
||||||
Days[2].setOnAction(event -> Controller.switchRoot(new MenuLevel(3)));
|
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 i = 0; i < 3; i++) {
|
||||||
for (int j = 1; j < 5; j++) {
|
for (int j = 1; j < 5; j++) {
|
||||||
if(i==0){
|
if(i==0){
|
||||||
@ -77,28 +87,24 @@ public class MenuLevel extends GridPane {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0;i<=2;i++){
|
for(int i=0;i<=2;i++){
|
||||||
Columns[i] = new ColumnConstraints();
|
Columns[i] = new ColumnConstraints();
|
||||||
Columns[i].setPercentWidth(33);
|
Columns[i].setPercentWidth(33);
|
||||||
getColumnConstraints().addAll(Columns[i]);
|
getColumnConstraints().addAll(Columns[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i= 0;i<=4;i++){
|
for (int i= 0;i<=4;i++){
|
||||||
Rows[i] = new RowConstraints();
|
Rows[i] = new RowConstraints();
|
||||||
Rows[i].setPercentHeight(20);
|
Rows[i].setPercentHeight(20);
|
||||||
getRowConstraints().addAll(Rows[i]);
|
getRowConstraints().addAll(Rows[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
setHgap(20);
|
setHgap(20);
|
||||||
setVgap(20);
|
setVgap(20);
|
||||||
setPadding(new Insets(20,10,10,20));
|
setPadding(new Insets(20,10,10,20));
|
||||||
getStyleClass().add("GridPane");
|
getStyleClass().add("GridPane");
|
||||||
getStylesheets().add(String.valueOf(getClass().getResource("StyleMenuAcceuil.css")));
|
getStylesheets().add(String.valueOf(getClass().getResource("StyleMenuAcceuil.css")));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user