/** * CLASS LAUNCHER * * Fenêtre de configuration du jeu préalablement au lancement d'une partie * * @author François Autin * */ package launcher; import gameplay.match.*; import javafx.application.Application; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.ChoiceBox; import javafx.stage.Stage; import javafx.stage.StageStyle; import javafx.fxml.*; import java.util.HashMap; public class Launcher extends Application { public static Launcher pointer; private static Settings setter; private HashMap arraysettings; public Launcher() { pointer = this; try { setter = new Settings(); } catch (Exception e) { e.printStackTrace(); System.exit(1); } arraysettings = new HashMap(); } /* * Start method is used by Launcher as an implementation of the Application class to create a JavaFX thread to display the GUI window */ public void start(Stage primaryStage) throws Exception { Parent root = FXMLLoader.load(getClass().getResource("launcher.fxml")); Scene main = new Scene(root); @SuppressWarnings("unchecked") ChoiceBox cb = (ChoiceBox) main.lookup("#resolution"); ObservableList 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()); } primaryStage.initStyle(StageStyle.UNDECORATED); primaryStage.setTitle("Boulevard Combattant"); primaryStage.setScene(main); primaryStage.show(); } public static void runGame() { try { setter.setSettings(); match.main(null); } catch (Exception e) { e.printStackTrace(); System.exit(1); } } @FXML public void launch() { Launcher.runGame(); } @FXML public void settings() { } @FXML public void quit() { System.exit(0); } @FXML public void website() { getHostServices().showDocument("https://gitlab.istic.univ-rennes1.fr/fautin/jeu-de-combat"); } public HashMap getArraysettings() { return arraysettings; } }