package com.example.demo;

import javafx.application.Application;
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.control.MenuButton;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.RowConstraints;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.stage.Stage;

import java.io.IOException;
import java.util.Objects;

public class HelloApplication extends Application {
    private Stage stage;
    //set up scene one
    private Scene Menu;
    private BorderPane BdP;

    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;
    //button for levele
    private MenuButton select_day;
    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;

    public void start(Stage primaryStage) {
        //set up the page
        stage = primaryStage;
        stage.setTitle("ROAD TO MASTER YOU");
        Menu = createMenu();
        Level_menu = createLevel_menu();

        stage.setScene(Menu);
        stage.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");
        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");
        select_day = new MenuButton("Select day");

        //set up of the button
        GdP.add(select_day,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(select_day, HPos.CENTER);
        GridPane.setHalignment(bck_menu, HPos.CENTER);


        return Level_menu;
    }
    public void switchScenes(Scene scene){
        stage.setScene(scene);

    }
    public static void main(String[] args) {
        launch(args);
    }
}


/***@Override
public void start(Stage primaryStage) {
    //set up the page
    primaryStage.setTitle("Road to Master You");
    BorderPane root = new BorderPane();
    Scene scene = new Scene(root,400,300);
    primaryStage.setScene(scene);
    primaryStage.show();

    //set up all the object needed for the menu
    Label title = new Label("Welcome to Road to Master You");
    Button Play = new Button("Play");
    Button Select_level = new Button("Select Level");
    Button Trophy = new Button("Trophy");

    //put all the object on the page
    root.setTop(title);
    root.setBottom(Trophy);
    root.setRight(Select_level);
    root.setLeft(Play);

    //adjust everything as I want (position,color)
    title.setTextFill(Color.GOLD);
    BorderPane.setAlignment(title,Pos.CENTER);
    BorderPane.setAlignment(Play,Pos.CENTER);
    BorderPane.setAlignment(Select_level,Pos.CENTER);
    BorderPane.setAlignment(Trophy,Pos.CENTER);
    scene.getStylesheets().add("style.css"); //todo found why there is no link btw file

    //Switch scene
    Select_level.setOnAction(event -> {
        SelectLevel secondWindow = new SelectLevel();
        secondWindow.show();
    });

}
}
*/