package school_project.Menu;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import school_project.Controller;
import school_project.MapGenerator;

public class MenuAccueil extends StackPane {

    public MenuAccueil(){
        super();
        //create all the objet that I need
        ChoiceBox SlctDifficulty = new ChoiceBox();
        SlctDifficulty.getItems().addAll("Easy", "Medium", "Difficult");
        Label RdmLvl = new Label("Random Level : ");
        Button SelectLevel= new Button("Select Level");
        Label Title = new Label("Welcome to Road to Master");
        SlctDifficulty.setOnAction(event -> {
            String choosediff = SlctDifficulty.getSelectionModel().getSelectedItem().toString();
           switch(choosediff){
                case "Easy":
                    SlctDifficulty.setOnAction(event1 -> MapGenerator.generate(MapGenerator.Difficulty.Easy));
                    break;
                case "Medium":
                    SlctDifficulty.setOnAction(event1 -> MapGenerator.generate(MapGenerator.Difficulty.Medium));
                    break;
               case "Difficult":
                    SlctDifficulty.setOnAction(event1 -> MapGenerator.generate(MapGenerator.Difficulty.Difficult));
                    break;
            }});


        //set up all the Button where I need
        getChildren().addAll(Title,SlctDifficulty,SelectLevel,RdmLvl);
        RdmLvl.setFont(Font.font(25));
        RdmLvl.setTextFill(Color.GOLD);
        Title.setFont(Font.font(40));
        Title.setTextFill(Color.RED);
        setAlignment(Title, Pos.TOP_CENTER);
        setAlignment(SlctDifficulty,Pos.CENTER_LEFT);
        setAlignment(SelectLevel,Pos.CENTER_RIGHT);
        setAlignment(RdmLvl, Pos.CENTER_LEFT);

        setMargin(RdmLvl,new Insets(0,0,0,100));
        setMargin(SlctDifficulty,new Insets(0,0,0,300));
        setMargin(SelectLevel,new Insets(0,300,0,0));
        setMargin(Title,new Insets(200,0,0,0));

        SelectLevel.setOnAction(event ->  Controller.switchRoot(new MenuLevel(1)));

        getStyleClass().add("BorderPane");
        getStylesheets().add(String.valueOf(getClass().getResource("StyleMenuAcceuil.css")));



    }



}
