menu #43
@ -1,6 +1,3 @@
|
||||
/*
|
||||
* This Java source file was generated by the Gradle 'init' task.
|
||||
*/
|
||||
package school_project;
|
||||
|
||||
import javafx.application.Application;
|
||||
@ -10,14 +7,13 @@ import javafx.scene.Scene;
|
||||
import javafx.scene.input.KeyCombination;
|
||||
import javafx.stage.Screen;
|
||||
import javafx.stage.Stage;
|
||||
import school_project.Parsers.FileParserFactory;
|
||||
import school_project.Menu.MenuAcceuil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class Controller extends Application {
|
||||
private Stage stage;
|
||||
private static Stage stage;
|
||||
Parent root;
|
||||
public static Vec2 screen_size;
|
||||
|
||||
@ -36,14 +32,20 @@ public class Controller extends Application {
|
||||
stage.setFullScreenExitHint("");
|
||||
primaryStage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
|
||||
|
||||
root = new GameUI(FileParserFactory.loadMapFromFile(new File(getClass().getResource("level11.level").getFile())));
|
||||
root = new MenuAcceuil();
|
||||
|
||||
Scene scene = new Scene(root, screen_size.x, screen_size.y);
|
||||
stage.setScene(scene);
|
||||
switchRoot(root);
|
||||
tonitch marked this conversation as resolved
|
||||
stage.show();
|
||||
}
|
||||
|
||||
|
||||
public static void switchRoot(Parent root){
|
||||
Scene scene = new Scene(root);
|
||||
stage.setScene(scene);
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
launch();
|
||||
launch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
42
app/src/main/java/school_project/Menu/MenuAcceuil.java
Normal file
42
app/src/main/java/school_project/Menu/MenuAcceuil.java
Normal file
@ -0,0 +1,42 @@
|
||||
package school_project.Menu;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.text.Font;
|
||||
import school_project.Controller;
|
||||
public class MenuAcceuil extends BorderPane {
|
||||
|
||||
|
||||
public MenuAcceuil(){
|
||||
super();
|
||||
tonitch marked this conversation as resolved
tonitch
commented
Ces Variable (sauf Ces Variable (sauf `selectlevel`) peuvent
|
||||
//create all the objet that i need
|
||||
Button Play = new Button("Play");
|
||||
Button SelectLevel= new Button("Select Level");
|
||||
Button Trophy = new Button("Trophy");
|
||||
Label Title = new Label("Welcome to Road to Master");
|
||||
//set up all the Button where i need
|
||||
setTop(Title);
|
||||
setLeft(Play);
|
||||
setRight(SelectLevel);
|
||||
setBottom(Trophy);
|
||||
Title.setFont(Font.font(20));
|
||||
Title.setTextFill(Color.GOLD);
|
||||
setAlignment(Title, Pos.CENTER);
|
||||
setAlignment(Play,Pos.CENTER);
|
||||
setAlignment(SelectLevel,Pos.CENTER);
|
||||
setAlignment(Trophy,Pos.CENTER);
|
||||
setPadding(new Insets(20,60,20,60));
|
||||
SelectLevel.setOnAction(event -> Controller.switchRoot(new MenuLevel(1)));
|
||||
getStyleClass().add("BorderPane");
|
||||
tonitch marked this conversation as resolved
tonitch
commented
a enlever a enlever
|
||||
getStylesheets().add(String.valueOf(getClass().getResource("StyleMenuAcceuil.css")));
|
||||
|
||||
|
||||
|
||||
tonitch marked this conversation as resolved
tonitch
commented
pour plus de lisibilitée quelques espaces seraient cool pour plus de lisibilitée quelques espaces seraient cool
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
110
app/src/main/java/school_project/Menu/MenuLevel.java
Normal file
110
app/src/main/java/school_project/Menu/MenuLevel.java
Normal file
@ -0,0 +1,110 @@
|
||||
package school_project.Menu;
|
||||
|
||||
import javafx.geometry.HPos;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.layout.ColumnConstraints;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.RowConstraints;
|
||||
import school_project.Controller;
|
||||
|
||||
public class MenuLevel extends GridPane {
|
||||
private int StartLevel;
|
||||
public MenuLevel(int choose_day) {
|
||||
|
||||
//create all Object that I need
|
||||
RowConstraints[] Rows = new RowConstraints[5];
|
||||
tonitch marked this conversation as resolved
tonitch
commented
Peuvent être locales Peuvent être locales
|
||||
ColumnConstraints[] Columns = new ColumnConstraints[3];
|
||||
Button[] Days = new Button[3];
|
||||
Button BckMenu = new Button("Back to menu");
|
||||
|
||||
BckMenu.setOnAction(event -> Controller.switchRoot(new MenuAcceuil()));
|
||||
setHalignment(BckMenu,HPos.CENTER);
|
||||
add(BckMenu,2,4);
|
||||
|
||||
|
||||
for (int i = 0; i < Days.length; i++){
|
||||
Days[i] = new Button("Day"+(i+1));
|
||||
}
|
||||
|
||||
//it's here that I know which day I can show on the screen
|
||||
|
||||
if (choose_day == 1) {
|
||||
StartLevel = 1;
|
||||
add(Days[1],0,0);
|
||||
add(Days[2],2,0);
|
||||
setHalignment(Days[1], HPos.CENTER);
|
||||
setHalignment(Days[2], HPos.CENTER);
|
||||
}
|
||||
|
||||
else if (choose_day == 2) {
|
||||
StartLevel = 11;
|
||||
add(Days[0], 0, 0);
|
||||
add(Days[2], 2, 0);
|
||||
setHalignment(Days[0], HPos.CENTER);
|
||||
setHalignment(Days[2], HPos.CENTER);
|
||||
}
|
||||
|
||||
else if (choose_day == 3) {
|
||||
StartLevel = 21;
|
||||
add(Days[0], 0, 0);
|
||||
add(Days[1], 2, 0);
|
||||
setHalignment(Days[0], HPos.CENTER);
|
||||
setHalignment(Days[1], HPos.CENTER);
|
||||
}
|
||||
|
||||
Days[0].setOnAction(event -> Controller.switchRoot(new MenuLevel(1)));
|
||||
Days[1].setOnAction(event -> Controller.switchRoot(new MenuLevel(2)));
|
||||
Days[2].setOnAction(event -> Controller.switchRoot(new MenuLevel(3)));
|
||||
|
||||
//It's here that I put all buttons where I need (base on column not row)
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 1; j < 5; j++) {
|
||||
if(i==0){
|
||||
Button Level = new Button("level "+(StartLevel));
|
||||
StartLevel+=3;
|
||||
add(Level,i,j);
|
||||
setHalignment(Level,HPos.CENTER);
|
||||
if(j==4){
|
||||
StartLevel-=11;
|
||||
}
|
||||
}
|
||||
else if(i==1&&j!=4) {
|
||||
Button Level = new Button("level "+(StartLevel));
|
||||
StartLevel += 3;
|
||||
add(Level, i, j);
|
||||
setHalignment(Level,HPos.CENTER);
|
||||
if (j == 3) {
|
||||
StartLevel -=8;
|
||||
|
||||
}
|
||||
}
|
||||
else if(i==2&&j!=4){
|
||||
Button Level = new Button("level "+(StartLevel));
|
||||
StartLevel+=3;
|
||||
add(Level,i,j);
|
||||
setHalignment(Level,HPos.CENTER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0;i<=2;i++){
|
||||
Columns[i] = new ColumnConstraints();
|
||||
Columns[i].setPercentWidth(33);
|
||||
getColumnConstraints().addAll(Columns[i]);
|
||||
}
|
||||
|
||||
for (int i= 0;i<=4;i++){
|
||||
Rows[i] = new RowConstraints();
|
||||
Rows[i].setPercentHeight(20);
|
||||
getRowConstraints().addAll(Rows[i]);
|
||||
}
|
||||
tonitch marked this conversation as resolved
tonitch
commented
pourquoi y'a plein d'espaces pourquoi y'a plein d'espaces
|
||||
|
||||
setHgap(20);
|
||||
setVgap(20);
|
||||
setPadding(new Insets(20,10,10,20));
|
||||
getStyleClass().add("GridPane");
|
||||
getStylesheets().add(String.valueOf(getClass().getResource("StyleMenuAcceuil.css")));
|
||||
}
|
||||
}
|
||||
|
BIN
app/src/main/resources/school_project/Menu/BackGround-menu.jpg
Normal file
BIN
app/src/main/resources/school_project/Menu/BackGround-menu.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 MiB |
Binary file not shown.
After Width: | Height: | Size: 423 KiB |
@ -0,0 +1,8 @@
|
||||
.BorderPane{
|
||||
-fx-background-image: url("BackGround-menu.jpg");
|
||||
-fx-background-position:center;
|
||||
}
|
||||
.GridPane{
|
||||
-fx-background-image: url("Background-select-level.jpg");
|
||||
-fx-background-position:right;
|
||||
}
|
Loading…
Reference in New Issue
Block a user
pourquoi ?