From 25a6782f3cf4f8365440d562d9778707ece42222 Mon Sep 17 00:00:00 2001 From: Mat Date: Fri, 28 Apr 2023 11:28:10 +0200 Subject: [PATCH] beginning of the final interface --- .../main/java/school_project/Controller.java | 220 ++++++++++++++++-- 1 file changed, 205 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/school_project/Controller.java b/app/src/main/java/school_project/Controller.java index c979cac..a51d5b0 100644 --- a/app/src/main/java/school_project/Controller.java +++ b/app/src/main/java/school_project/Controller.java @@ -1,32 +1,222 @@ -/* - * This Java source file was generated by the Gradle 'init' task. - */ package school_project; import javafx.application.Application; -import javafx.scene.Group; +import javafx.geometry.HPos; +import javafx.geometry.Insets; +import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; +import javafx.scene.control.Label; + +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; + + public class Controller extends Application { + private Stage stage; + //set up scene one + private Scene Menu; + private BorderPane BdP; - @Override - public void start(Stage primaryStage) throws Exception { - primaryStage.setTitle("test"); - Button btn = new Button("test"); - btn.setOnAction(event -> System.out.println("hey")); + 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; + private Button _11; + private Button _12; + private Button _13; + private Button _14; + private Button _15; + private Button _16; + private Button _17; + private Button _18; + private Button _19; + private Button _20; - Group root = new Group(); - root.getChildren().add(btn); + //button for level + 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; - Scene scene = new Scene(root, 300,300); - primaryStage.setScene(scene); + public void start(Stage primaryStage) { + //set up the page + stage = primaryStage; + stage.setTitle("ROAD TO MASTER YOU"); + Menu = createMenu(); + Level_menu = createLevel_menu(); + Level_menu2 = createLevel_Menu2(); + + stage.setScene(Menu); + stage.show(); - primaryStage.show(); } + private Scene createMenu(){ + Play = new Button("Play"); + Trophy = new Button("Trophy"); + Select_level = new Button("Select Level"); + Select_level.setOnAction(event -> switchScenes(Level_menu)); + title = new Label("Welcome to road to master you"); + title.setFont(Font.font(20)); + title.setTextFill(Color.GOLD); + BdP = new BorderPane(null,title,Select_level,Trophy,Play); + Menu = new Scene(BdP,700,400); + BorderPane.setAlignment(title,Pos.CENTER); + BorderPane.setAlignment(Play,Pos.CENTER); + BorderPane.setAlignment(Select_level,Pos.CENTER); + BorderPane.setAlignment(Trophy,Pos.CENTER); + //Menu.getStylesheets().add("style.css"); todo creat a file css + BdP.setPadding(new Insets(20,60,20,60)); + return Menu; + } + private Scene createLevel_menu(){ + bck_menu = new Button("Back to the menu"); + bck_menu.setOnAction(event -> switchScenes(Menu)); + GdP = new GridPane(); + Level_menu = new Scene(GdP,700,400); + _1 = new Button("1"); + _2 = new Button("2"); + _3 = new Button("3"); + _4 = new Button("4"); + _5 = new Button("5"); + _6 = new Button("6"); + _7 = new Button("7"); + _8 = new Button("8"); + _9 = new Button("9"); + _10 = new Button("10"); + Day_2 = new Button("Day 2"); + Day_3 = new Button("Day 3"); + + //set up of the button + GdP.add(Day_2,1,0); + GdP.add(Day_3,1,0); + GdP.add(_1,0,1); + GdP.add(_2,1,1); + GdP.add(_3,2,1); + GdP.add(_4,0,2); + GdP.add(_5,1,2); + GdP.add(_6,2,2); + GdP.add(_7,0,3); + GdP.add(_8,1,3); + GdP.add(_9,2,3); + GdP.add(_10,1,4); + GdP.add(bck_menu,2,4); + //set up gap and padding and everything else + GdP.setHgap(20); + GdP.setVgap(20); + GdP.setPadding(new Insets(40,20,20,40)); + 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)); + GdP2 = new GridPane(); + + //set up the menubutton + Day_1 = new Button("Day 1"); + Day_3 = new Button("Day 3"); + //set up link + Day_1.setOnAction(event -> switchScenes(Level_menu)); + //add all the button for the level + GdP2.add(Day_1,1,0); + GdP2.add(Day_3,1,0); + _11 = new Button("11"); + _12 = new Button("12"); + _13 = new Button("13"); + _14 = new Button("14"); + _15 = new Button("15"); + _16 = new Button("16"); + _17 = new Button("17"); + _18 = new Button("18"); + _19 = new Button("19"); + _20 = new Button("20"); + Day_1 = new Button("Day 1"); + Day_3 = new Button("Day 3"); + + GdP2.add(_11,0,1); + GdP2.add(_12,1,1); + GdP2.add(_13,2,1); + GdP2.add(_14,0,2); + GdP2.add(_15,1,2); + GdP2.add(_16,2,2); + GdP2.add(_17,0,3); + GdP2.add(_18,1,3); + GdP2.add(_19,2,3); + GdP2.add(_20,1,4); + GdP2.add(bck_menu,2,4); + GridPane.setHalignment(_11, HPos.CENTER); + GridPane.setHalignment(_12, HPos.CENTER); + GridPane.setHalignment(_13, HPos.CENTER); + GridPane.setHalignment(_14, HPos.CENTER); + GridPane.setHalignment(_15, HPos.CENTER); + GridPane.setHalignment(_16, HPos.CENTER); + GridPane.setHalignment(_17, HPos.CENTER); + GridPane.setHalignment(_18, HPos.CENTER); + GridPane.setHalignment(_19, HPos.CENTER); + GridPane.setHalignment(_20, HPos.CENTER); + GridPane.setHalignment(Day_1, HPos.LEFT); + GridPane.setHalignment(Day_3, HPos.RIGHT); + GridPane.setHalignment(bck_menu, HPos.CENTER); + + return Level_menu2; + + + + } + public void switchScenes(Scene scene){ + stage.setScene(scene); + + } public static void main(String[] args) { - launch(); + launch(args); } } + +