2021-05-03 02:29:11 +02:00
|
|
|
/**
|
|
|
|
* CLASS LAUNCHER
|
|
|
|
*
|
|
|
|
* Fenêtre de configuration du jeu préalablement au lancement d'une partie
|
|
|
|
*
|
|
|
|
* @author François Autin
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
package launcher;
|
|
|
|
|
2021-06-10 14:07:06 +02:00
|
|
|
import gameplay.match.*;
|
2021-05-27 03:02:36 +02:00
|
|
|
import javafx.application.Application;
|
2021-06-10 14:07:06 +02:00
|
|
|
import javafx.collections.FXCollections;
|
|
|
|
import javafx.collections.ObservableList;
|
2021-05-27 03:02:36 +02:00
|
|
|
import javafx.scene.Parent;
|
|
|
|
import javafx.scene.Scene;
|
2021-06-10 14:07:06 +02:00
|
|
|
import javafx.scene.control.ChoiceBox;
|
2021-05-27 03:02:36 +02:00
|
|
|
import javafx.stage.Stage;
|
2021-06-03 03:46:38 +02:00
|
|
|
import javafx.stage.StageStyle;
|
2021-05-27 03:02:36 +02:00
|
|
|
import javafx.fxml.*;
|
2021-06-10 14:07:06 +02:00
|
|
|
import java.util.HashMap;
|
2021-06-03 00:47:49 +02:00
|
|
|
|
2021-05-27 03:02:36 +02:00
|
|
|
public class Launcher extends Application {
|
|
|
|
|
2021-06-03 00:47:49 +02:00
|
|
|
public static Launcher pointer;
|
|
|
|
private static Settings setter;
|
2021-06-10 14:07:06 +02:00
|
|
|
private HashMap<String, Object> arraysettings;
|
2021-06-03 00:47:49 +02:00
|
|
|
|
|
|
|
public Launcher() {
|
|
|
|
pointer = this;
|
|
|
|
try {
|
|
|
|
setter = new Settings();
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
System.exit(1);
|
|
|
|
}
|
2021-06-10 14:07:06 +02:00
|
|
|
arraysettings = new HashMap<String, Object>();
|
2021-06-03 00:47:49 +02:00
|
|
|
}
|
|
|
|
|
2021-05-28 01:15:50 +02:00
|
|
|
/*
|
|
|
|
* Start method is used by Launcher as an implementation of the Application class to create a JavaFX thread to display the GUI window
|
|
|
|
*/
|
2021-05-27 03:02:36 +02:00
|
|
|
public void start(Stage primaryStage) throws Exception {
|
2021-05-27 03:14:20 +02:00
|
|
|
|
2021-06-03 01:53:32 +02:00
|
|
|
Parent root = FXMLLoader.load(getClass().getResource("launcher.fxml"));
|
2021-05-28 01:15:50 +02:00
|
|
|
|
|
|
|
Scene main = new Scene(root);
|
2021-05-03 02:29:11 +02:00
|
|
|
|
2021-06-10 14:07:06 +02:00
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
ChoiceBox<String> cb = (ChoiceBox<String>) main.lookup("#resolution");
|
|
|
|
|
|
|
|
ObservableList<String> availableres = FXCollections.observableArrayList("640x480", "800x600", "1024x768", "1280x720", "1366x768", "1600x900", "1920x1080");
|
|
|
|
cb.setItems(availableres);
|
|
|
|
if (!availableres.contains(setter.getResolution())) {
|
|
|
|
cb.setValue("640x480");
|
|
|
|
} else {
|
|
|
|
cb.setValue(setter.getResolution());
|
|
|
|
}
|
|
|
|
|
2021-06-03 03:46:38 +02:00
|
|
|
primaryStage.initStyle(StageStyle.UNDECORATED);
|
2021-05-28 01:15:50 +02:00
|
|
|
primaryStage.setTitle("Boulevard Combattant");
|
2021-05-27 03:14:20 +02:00
|
|
|
primaryStage.setScene(main);
|
|
|
|
primaryStage.show();
|
2021-06-03 00:47:49 +02:00
|
|
|
|
2021-05-03 02:29:11 +02:00
|
|
|
}
|
|
|
|
|
2021-06-03 00:47:49 +02:00
|
|
|
public static void runGame() {
|
|
|
|
try {
|
|
|
|
setter.setSettings();
|
2021-06-10 14:07:06 +02:00
|
|
|
match.main(null);
|
2021-06-03 00:47:49 +02:00
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
System.exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-03 03:46:38 +02:00
|
|
|
@FXML
|
|
|
|
public void launch() {
|
|
|
|
Launcher.runGame();
|
|
|
|
}
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
public void settings() {
|
2021-06-03 00:47:49 +02:00
|
|
|
|
|
|
|
}
|
2021-06-03 03:46:38 +02:00
|
|
|
|
|
|
|
@FXML
|
|
|
|
public void quit() {
|
|
|
|
System.exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
public void website() {
|
|
|
|
getHostServices().showDocument("https://gitlab.istic.univ-rennes1.fr/fautin/jeu-de-combat");
|
|
|
|
}
|
2021-06-03 00:47:49 +02:00
|
|
|
|
2021-06-10 14:07:06 +02:00
|
|
|
public HashMap<String, Object> getArraysettings() {
|
|
|
|
return arraysettings;
|
|
|
|
}
|
|
|
|
|
2021-05-03 02:29:11 +02:00
|
|
|
}
|