Link the choiceBox to some Action but doesn't generate level :')
This commit is contained in:
parent
e1f7d7a729
commit
5593f1834a
@ -3,6 +3,7 @@ package school_project;
|
|||||||
import javafx.scene.Group;
|
import javafx.scene.Group;
|
||||||
import javafx.scene.input.MouseButton;
|
import javafx.scene.input.MouseButton;
|
||||||
import school_project.Menu.MenuAccueil;
|
import school_project.Menu.MenuAccueil;
|
||||||
|
import school_project.Menu.ScreenLevelFinish;
|
||||||
import school_project.Utils.MatrixShape;
|
import school_project.Utils.MatrixShape;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -72,7 +73,7 @@ public class GameUI extends Group{
|
|||||||
_piece.setLayoutY(grid.getLayoutY() + p.getPosition().x * (SEGMENT_SIZE+SPACE_SIZE));
|
_piece.setLayoutY(grid.getLayoutY() + p.getPosition().x * (SEGMENT_SIZE+SPACE_SIZE));
|
||||||
}
|
}
|
||||||
if(level.gameDone()){
|
if(level.gameDone()){
|
||||||
Controller.switchRoot(new MenuAccueil());
|
Controller.switchRoot(new ScreenLevelFinish());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -8,16 +8,32 @@ import javafx.scene.layout.StackPane;
|
|||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.text.Font;
|
import javafx.scene.text.Font;
|
||||||
import school_project.Controller;
|
import school_project.Controller;
|
||||||
|
import school_project.MapGenerator;
|
||||||
|
|
||||||
public class MenuAccueil extends StackPane {
|
public class MenuAccueil extends StackPane {
|
||||||
|
|
||||||
public MenuAccueil(){
|
public MenuAccueil(){
|
||||||
super();
|
super();
|
||||||
//create all the objet that I need
|
//create all the objet that I need
|
||||||
ChoiceBox SlctDifficulty = new ChoiceBox();
|
ChoiceBox SlctDifficulty = new ChoiceBox();
|
||||||
SlctDifficulty.getItems().addAll("Easy", "Medium", "Hard");
|
SlctDifficulty.getItems().addAll("Easy", "Medium", "Difficult");
|
||||||
Label RdmLvl = new Label("Random Level : ");
|
Label RdmLvl = new Label("Random Level : ");
|
||||||
Button SelectLevel= new Button("Select Level");
|
Button SelectLevel= new Button("Select Level");
|
||||||
Label Title = new Label("Welcome to Road to Master");
|
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
|
//set up all the Button where I need
|
||||||
getChildren().addAll(Title,SlctDifficulty,SelectLevel,RdmLvl);
|
getChildren().addAll(Title,SlctDifficulty,SelectLevel,RdmLvl);
|
||||||
@ -36,6 +52,7 @@ public class MenuAccueil extends StackPane {
|
|||||||
setMargin(Title,new Insets(200,0,0,0));
|
setMargin(Title,new Insets(200,0,0,0));
|
||||||
|
|
||||||
SelectLevel.setOnAction(event -> Controller.switchRoot(new MenuLevel(1)));
|
SelectLevel.setOnAction(event -> Controller.switchRoot(new MenuLevel(1)));
|
||||||
|
|
||||||
getStyleClass().add("BorderPane");
|
getStyleClass().add("BorderPane");
|
||||||
getStylesheets().add(String.valueOf(getClass().getResource("StyleMenuAcceuil.css")));
|
getStylesheets().add(String.valueOf(getClass().getResource("StyleMenuAcceuil.css")));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user