Add a Load Level Button
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Mat 2023-05-18 17:51:37 +02:00
parent 9ff205b4de
commit 95cc3e3897
2 changed files with 19 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import javafx.stage.Screen;
import javafx.stage.Stage; import javafx.stage.Stage;
import school_project.Menu.MenuAccueil; import school_project.Menu.MenuAccueil;
import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -19,6 +20,7 @@ public class Controller extends Application {
@Override @Override
public void start(Stage primaryStage) throws IOException { public void start(Stage primaryStage) throws IOException {
new File("save.slevel");
stage = primaryStage; stage = primaryStage;
screen_size = new Vec2( screen_size = new Vec2(
(int) Screen.getPrimary().getBounds().getWidth(), (int) Screen.getPrimary().getBounds().getWidth(),

View File

@ -10,7 +10,13 @@ import javafx.scene.text.Font;
import school_project.Controller; import school_project.Controller;
import school_project.GameUI; import school_project.GameUI;
import school_project.MapGenerator; import school_project.MapGenerator;
import school_project.Parsers.FileParser;
import school_project.Parsers.FileParserFactory;
import school_project.Parsers.SerializeParser.*;
import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException;
public class MenuAccueil extends StackPane { public class MenuAccueil extends StackPane {
@ -21,6 +27,7 @@ public class MenuAccueil extends StackPane {
SlctDifficulty.getItems().addAll("Easy", "Medium", "Difficult"); SlctDifficulty.getItems().addAll("Easy", "Medium", "Difficult");
Label RdmLvl = new Label("Random Level : "); Label RdmLvl = new Label("Random Level : ");
Button LoadLvl = new Button("Load game");
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 -> { SlctDifficulty.setOnAction(event -> {
@ -52,12 +59,13 @@ public class MenuAccueil extends StackPane {
}); });
//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,LoadLvl);
RdmLvl.setFont(Font.font(25)); RdmLvl.setFont(Font.font(25));
RdmLvl.setTextFill(Color.GOLD); RdmLvl.setTextFill(Color.GOLD);
Title.setFont(Font.font(40)); Title.setFont(Font.font(40));
Title.setTextFill(Color.RED); Title.setTextFill(Color.RED);
setAlignment(Title, Pos.TOP_CENTER); setAlignment(Title, Pos.TOP_CENTER);
setAlignment(LoadLvl,Pos.BOTTOM_CENTER);
setAlignment(SlctDifficulty,Pos.CENTER_LEFT); setAlignment(SlctDifficulty,Pos.CENTER_LEFT);
setAlignment(SelectLevel,Pos.CENTER_RIGHT); setAlignment(SelectLevel,Pos.CENTER_RIGHT);
setAlignment(RdmLvl, Pos.CENTER_LEFT); setAlignment(RdmLvl, Pos.CENTER_LEFT);
@ -66,8 +74,16 @@ public class MenuAccueil extends StackPane {
setMargin(SlctDifficulty,new Insets(0,0,0,300)); setMargin(SlctDifficulty,new Insets(0,0,0,300));
setMargin(SelectLevel,new Insets(0,300,0,0)); setMargin(SelectLevel,new Insets(0,300,0,0));
setMargin(Title,new Insets(200,0,0,0)); setMargin(Title,new Insets(200,0,0,0));
setMargin(LoadLvl,new Insets(0,0,200,0));
SelectLevel.setOnAction(event -> Controller.switchRoot(new MenuLevel(1))); SelectLevel.setOnAction(event -> Controller.switchRoot(new MenuLevel(1)));
LoadLvl.setOnAction(event -> {
try {
FileParserFactory.loadMapFromFile(new File("save.slevel"));
} catch (IOException e) {
throw new RuntimeException(e);
}
});
getStyleClass().add("BorderPane"); getStyleClass().add("BorderPane");
getStylesheets().add(String.valueOf(getClass().getResource("StyleMenuAcceuil.css"))); getStylesheets().add(String.valueOf(getClass().getResource("StyleMenuAcceuil.css")));