retry_level #73

Merged
Mat_02 merged 2 commits from retry_level into master 2023-05-18 19:31:48 +02:00
2 changed files with 16 additions and 3 deletions

View File

@ -77,7 +77,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 ScreenLevelFinish()); Controller.switchRoot(new ScreenLevelFinish(level));
} }
} }
}); });

View File

@ -9,11 +9,15 @@ import javafx.scene.control.Label;
import javafx.scene.layout.StackPane; import javafx.scene.layout.StackPane;
import javafx.scene.text.Font; import javafx.scene.text.Font;
import school_project.Controller; import school_project.Controller;
import school_project.GameUI;
import school_project.Map;
import java.io.FileNotFoundException;
public class ScreenLevelFinish extends StackPane { public class ScreenLevelFinish extends StackPane {
public ScreenLevelFinish(){ public ScreenLevelFinish(Map lastlevel){
super(); super();
Button retry = new Button("Retry Level");
Label CongraMess = new Label(" LEVEL DONE GREAT JOB "); Label CongraMess = new Label(" LEVEL DONE GREAT JOB ");
CongraMess.setFont(Font.font(40)); CongraMess.setFont(Font.font(40));
Button BckMenu = new Button("Back to Menu"); Button BckMenu = new Button("Back to Menu");
@ -23,14 +27,23 @@ public class ScreenLevelFinish extends StackPane {
BckMenu.setOnAction(event -> Controller.switchRoot(new MenuAccueil())); BckMenu.setOnAction(event -> Controller.switchRoot(new MenuAccueil()));
ChooseLvl.setOnAction(event -> Controller.switchRoot(new MenuLevel(1))); ChooseLvl.setOnAction(event -> Controller.switchRoot(new MenuLevel(1)));
retry.setOnAction(event -> {
try {
Controller.switchRoot(new GameUI(lastlevel));
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
});
getChildren().addAll(BckMenu,ChooseLvl,CongraMess); getChildren().addAll(BckMenu,ChooseLvl,CongraMess,retry);
setAlignment(retry,Pos.BOTTOM_CENTER);
setAlignment(BckMenu, Pos.CENTER_RIGHT); setAlignment(BckMenu, Pos.CENTER_RIGHT);
setAlignment(ChooseLvl, Pos.CENTER_LEFT); setAlignment(ChooseLvl, Pos.CENTER_LEFT);
setAlignment(CongraMess, Pos.TOP_CENTER); setAlignment(CongraMess, Pos.TOP_CENTER);
setMargin(BckMenu, new Insets(0,300,0,0 )); setMargin(BckMenu, new Insets(0,300,0,0 ));
setMargin(ChooseLvl,new Insets(0,0,0,300)); setMargin(ChooseLvl,new Insets(0,0,0,300));
setMargin(CongraMess,new Insets(300,0,0,0)); setMargin(CongraMess,new Insets(300,0,0,0));
setMargin(retry,new Insets(0,0,300,0));
getStyleClass().add("StackPane"); getStyleClass().add("StackPane");
getStylesheets().add(String.valueOf(getClass().getResource("StyleMenuAcceuil.css"))); getStylesheets().add(String.valueOf(getClass().getResource("StyleMenuAcceuil.css")));