Make a Button to load the previous game done by the player in case if he want to do it one more time(#73)
All checks were successful
continuous-integration/drone/push Build is passing

Make a Button to load the previous game done by the player in case if he want to do it one more time

Co-authored-by: Mat <diletomatteo@gmail.com>
Reviewed-on: #73
Reviewed-by: Debucquoy Anthony <d.tonitch@gmail.com>
This commit is contained in:
Mat_02 2023-05-18 19:31:47 +02:00
parent 8c8dacadd0
commit fed275ba09
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));
}
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.text.Font;
import school_project.Controller;
import school_project.GameUI;
import school_project.Map;
import java.io.FileNotFoundException;
public class ScreenLevelFinish extends StackPane {
public ScreenLevelFinish(){
public ScreenLevelFinish(Map lastlevel){
super();
Button retry = new Button("Retry Level");
Label CongraMess = new Label(" LEVEL DONE GREAT JOB ");
CongraMess.setFont(Font.font(40));
Button BckMenu = new Button("Back to Menu");
@ -23,14 +27,23 @@ public class ScreenLevelFinish extends StackPane {
BckMenu.setOnAction(event -> Controller.switchRoot(new MenuAccueil()));
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(ChooseLvl, Pos.CENTER_LEFT);
setAlignment(CongraMess, Pos.TOP_CENTER);
setMargin(BckMenu, new Insets(0,300,0,0 ));
setMargin(ChooseLvl,new Insets(0,0,0,300));
setMargin(CongraMess,new Insets(300,0,0,0));
setMargin(retry,new Insets(0,0,300,0));
getStyleClass().add("StackPane");
getStylesheets().add(String.valueOf(getClass().getResource("StyleMenuAcceuil.css")));