Make operational and also organize all the buttons
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
a43e3b150a
commit
8110a93910
@ -1,45 +1,40 @@
|
|||||||
package school_project;
|
package school_project;
|
||||||
|
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.geometry.HPos;
|
|
||||||
import javafx.geometry.Insets;
|
|
||||||
import javafx.geometry.Pos;
|
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.Button;
|
|
||||||
import javafx.scene.control.Label;
|
|
||||||
|
|
||||||
import javafx.scene.control.Menu;
|
|
||||||
import javafx.scene.layout.BorderPane;
|
|
||||||
import javafx.scene.layout.ColumnConstraints;
|
|
||||||
import javafx.scene.layout.GridPane;
|
|
||||||
import javafx.scene.paint.Color;
|
|
||||||
import javafx.scene.text.Font;
|
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import school_project.Menu.MenuAcceuil;
|
import school_project.Menu.MenuAcceuil;
|
||||||
import school_project.Menu.MenuLevelDay1;
|
import school_project.Menu.MenuLevel;
|
||||||
import school_project.Menu.MenuLevelDay2;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class Controller extends Application {
|
public class Controller extends Application {
|
||||||
private Stage stage;
|
private static Stage stage;
|
||||||
Parent root;
|
Parent root;
|
||||||
|
|
||||||
|
|
||||||
public void start(Stage primaryStage) {
|
public void start(Stage primaryStage) {
|
||||||
//set up the page
|
//set up the page
|
||||||
|
|
||||||
root = new MenuAcceuil();
|
root = new MenuAcceuil();
|
||||||
stage = primaryStage;
|
stage = primaryStage;
|
||||||
stage.setTitle("ROAD TO MASTER YOU");
|
stage.setTitle("ROAD TO MASTER YOU");
|
||||||
stage.setScene(new Scene(root));
|
stage.setScene(new Scene(root));
|
||||||
stage.show();
|
stage.show();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void switchScenes(Scene scene){
|
public static void switchRoot(Parent root){
|
||||||
stage.setScene(scene);
|
stage.setScene(new Scene(root));
|
||||||
|
|
||||||
}
|
}
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
launch(args);
|
launch(args);
|
||||||
|
@ -1,16 +1,12 @@
|
|||||||
package school_project.Menu;
|
package school_project.Menu;
|
||||||
|
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.Scene;
|
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.layout.BorderPane;
|
import javafx.scene.layout.BorderPane;
|
||||||
import javafx.scene.layout.GridPane;
|
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.text.Font;
|
import javafx.scene.text.Font;
|
||||||
import javafx.stage.Stage;
|
import school_project.Controller;
|
||||||
|
|
||||||
public class MenuAcceuil extends BorderPane {
|
public class MenuAcceuil extends BorderPane {
|
||||||
private Button Play;
|
private Button Play;
|
||||||
public static Button SelectLevel;
|
public static Button SelectLevel;
|
||||||
@ -36,6 +32,7 @@ public class MenuAcceuil extends BorderPane {
|
|||||||
setAlignment(Trophy,Pos.CENTER);
|
setAlignment(Trophy,Pos.CENTER);
|
||||||
//Menu.getStylesheets().add("style.css"); todo creat a file css
|
//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)));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,69 +1,99 @@
|
|||||||
package school_project.Menu;
|
package school_project.Menu;
|
||||||
|
|
||||||
|
import javafx.geometry.HPos;
|
||||||
|
import javafx.geometry.Insets;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.layout.ColumnConstraints;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
|
import javafx.scene.layout.RowConstraints;
|
||||||
|
import school_project.Controller;
|
||||||
|
|
||||||
public class MenuLevel extends GridPane {
|
public class MenuLevel extends GridPane {
|
||||||
public Button BckMenu;
|
public Button BckMenu;
|
||||||
public Button[] Days = new Button[3];
|
public Button[] Days = new Button[3];
|
||||||
public int StartLevel;
|
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) {
|
||||||
GridPane GdP = new GridPane();
|
|
||||||
BckMenu = new Button("Back to menu");
|
BckMenu = new Button("Back to menu");
|
||||||
|
BckMenu.setOnAction(event -> Controller.switchRoot(new MenuAcceuil()));
|
||||||
|
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));
|
||||||
|
|
||||||
}
|
}
|
||||||
if (choose_day == 1) {
|
if (choose_day == 1) {
|
||||||
StartLevel = 1;
|
StartLevel = 1;
|
||||||
GdP.add(Days[1],0,0);
|
add(Days[1],0,0);
|
||||||
GdP.add(Days[2],1,0);
|
add(Days[2],2,0);
|
||||||
|
setHalignment(Days[1], HPos.CENTER);
|
||||||
|
setHalignment(Days[2], HPos.CENTER);
|
||||||
}
|
}
|
||||||
|
else if (choose_day == 2) {
|
||||||
if (choose_day == 2) {
|
|
||||||
StartLevel = 11;
|
StartLevel = 11;
|
||||||
GdP.add(Days[0], 0, 0);
|
add(Days[0], 0, 0);
|
||||||
GdP.add(Days[2], 1, 0);
|
add(Days[2], 2, 0);
|
||||||
|
setHalignment(Days[0], HPos.CENTER);
|
||||||
|
setHalignment(Days[2], HPos.CENTER);
|
||||||
}
|
}
|
||||||
if (choose_day == 3) {
|
else if (choose_day == 3) {
|
||||||
StartLevel = 21;
|
StartLevel = 21;
|
||||||
GdP.add(Days[0], 0, 0);
|
add(Days[0], 0, 0);
|
||||||
GdP.add(Days[1], 1, 0);
|
add(Days[1], 2, 0);
|
||||||
|
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)));
|
||||||
|
|
||||||
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){
|
||||||
Button Level = new Button(Integer.toString(StartLevel));
|
Button Level = new Button("level "+(StartLevel));
|
||||||
StartLevel+=3;
|
StartLevel+=3;
|
||||||
GdP.add(Level,i,j);
|
add(Level,i,j);
|
||||||
|
setHalignment(Level,HPos.CENTER);
|
||||||
if(j==4){
|
if(j==4){
|
||||||
StartLevel-=11;
|
StartLevel-=11;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(i==1&&j!=4) {
|
else if(i==1&&j!=4) {
|
||||||
Button Level = new Button(Integer.toString(StartLevel));
|
Button Level = new Button("level "+(StartLevel));
|
||||||
StartLevel += 3;
|
StartLevel += 3;
|
||||||
GdP.add(Level, i, j);
|
add(Level, i, j);
|
||||||
|
setHalignment(Level,HPos.CENTER);
|
||||||
if (j == 3) {
|
if (j == 3) {
|
||||||
StartLevel -=8;
|
StartLevel -=8;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(i==2&&j!=4){
|
else if(i==2&&j!=4){
|
||||||
Button Level = new Button(Integer.toString(StartLevel));
|
Button Level = new Button("level "+(StartLevel));
|
||||||
StartLevel+=3;
|
StartLevel+=3;
|
||||||
GdP.add(Level,i,j);
|
add(Level,i,j);
|
||||||
}
|
setHalignment(Level,HPos.CENTER);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
getChildren().addAll(GdP);
|
for(int i=0;i<=2;i++){
|
||||||
|
Columns[i] = new ColumnConstraints();
|
||||||
|
Columns[i].setPercentWidth(30);
|
||||||
|
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));
|
||||||
|
setGridLinesVisible(true);
|
||||||
|
alignmentProperty();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user