diff --git a/src/launcher/Launcher.java b/src/launcher/Launcher.java index 7c33e72..7c10e50 100644 --- a/src/launcher/Launcher.java +++ b/src/launcher/Launcher.java @@ -16,6 +16,9 @@ import javafx.collections.ObservableList; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.ChoiceBox; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.VBox; import javafx.scene.control.CheckBox; import javafx.stage.Stage; import javafx.stage.StageStyle; @@ -23,6 +26,7 @@ import javafx.fxml.*; import java.util.HashMap; import java.util.Map; +@SuppressWarnings("unchecked") public class Launcher extends Application { public static Launcher pointer; @@ -45,7 +49,6 @@ public class Launcher extends Application { * Start method is used by Launcher as an implementation of the Application class to create a JavaFX thread to display the GUI window */ - @SuppressWarnings("unchecked") public void start(Stage primaryStage) throws Exception { FXMLLoader loader = new FXMLLoader(getClass().getResource("launcher.fxml")); @@ -72,7 +75,21 @@ public class Launcher extends Application { fs.setSelected(false); } + VBox v1 = (VBox) namespace.get("p1"); + ChoiceBox b1 = (ChoiceBox) v1.getChildren().get(1); + VBox v2 = (VBox) namespace.get("p2"); + ChoiceBox b2 = (ChoiceBox) v2.getChildren().get(1); + ObservableList availablechar = FXCollections.observableArrayList("Blue"); + b1.setItems(availablechar); + b2.setItems(availablechar); + if(setter.getChar1().equals("blue")) { + b1.setValue("Blue"); + } + + if(setter.getChar2().equals("blue")) { + b2.setValue("Blue"); + } primaryStage.initStyle(StageStyle.UNDECORATED); primaryStage.setTitle("Boulevard Combattant"); @@ -81,7 +98,6 @@ public class Launcher extends Application { } - @SuppressWarnings("unchecked") @FXML public void runGame() { try { @@ -126,8 +142,15 @@ public class Launcher extends Application { CheckBox fs = (CheckBox) namespace.get("fullscreen"); pointer.arraysettings.put("fullscreen", fs.isSelected()); pointer.arraysettings.put("rounds", 3); - pointer.arraysettings.put("character1", "default"); - pointer.arraysettings.put("character2", "default"); + + VBox vp1 = (VBox) namespace.get("p1"); + ChoiceBox p1 = (ChoiceBox) vp1.getChildren().get(1); + pointer.arraysettings.put("character1", p1.getValue().toLowerCase()); + + VBox vp2 = (VBox) namespace.get("p2"); + ChoiceBox p2 = (ChoiceBox) vp2.getChildren().get(1); + pointer.arraysettings.put("character2", p2.getValue().toLowerCase()); + pointer.arraysettings.put("stage", "default"); setter.setSettings(); match.main(null); @@ -152,6 +175,36 @@ public class Launcher extends Application { public void website() { getHostServices().showDocument("https://gitlab.istic.univ-rennes1.fr/fautin/jeu-de-combat"); } + + @FXML + public void chp1() { + VBox v1 = (VBox) namespace.get("p1"); + ImageView iv1 = (ImageView) v1.getChildren().get(0); + ChoiceBox b1 = (ChoiceBox) v1.getChildren().get(1); + switch (b1.getValue()) { + case "Blue": + iv1.setImage(new Image("/launcher/charfaces/blue.png")); + break; + default: + iv1.setImage(new Image("/launcher/default.png")); + break; + } + } + + @FXML + public void chp2() { + VBox v1 = (VBox) namespace.get("p2"); + ImageView iv1 = (ImageView) v1.getChildren().get(0); + ChoiceBox b1 = (ChoiceBox) v1.getChildren().get(1); + switch (b1.getValue()) { + case "Blue": + iv1.setImage(new Image("/launcher/charfaces/blue.png")); + break; + default: + iv1.setImage(new Image("/launcher/default.png")); + break; + } + } public HashMap getArraysettings() { return arraysettings; diff --git a/src/launcher/Settings.java b/src/launcher/Settings.java index c243a90..8c706d7 100644 --- a/src/launcher/Settings.java +++ b/src/launcher/Settings.java @@ -27,7 +27,7 @@ public class Settings { String stage = (String) set.get("stage"); config.write(width, height, rounds, fullscreen, character1, character2, stage); } catch (Exception e) { - config.write(800, 600, 3, false, "default", "default", "default"); + config.write(800, 600, 3, false, "blue", "blue", "default"); System.out.println("Incorrect config file"); } } @@ -39,5 +39,13 @@ public class Settings { public boolean getFullscreen() { return config.fullscreen; } + + public String getChar1() { + return config.p1; + } + + public String getChar2() { + return config.p2; + } } diff --git a/src/launcher/charfaces/blue.png b/src/launcher/charfaces/blue.png new file mode 100644 index 0000000..53a4a90 Binary files /dev/null and b/src/launcher/charfaces/blue.png differ diff --git a/src/launcher/default.png b/src/launcher/default.png new file mode 100644 index 0000000..e7bdbef Binary files /dev/null and b/src/launcher/default.png differ diff --git a/src/launcher/launcher.fxml b/src/launcher/launcher.fxml index c980793..afd9403 100644 --- a/src/launcher/launcher.fxml +++ b/src/launcher/launcher.fxml @@ -19,7 +19,7 @@ + minWidth="280" prefHeight="1280"> @@ -61,18 +61,24 @@ - + - - - + + + + + + - + - - - + + + + + + diff --git a/src/launcher/style.css b/src/launcher/style.css index 4016a3d..762e5be 100644 --- a/src/launcher/style.css +++ b/src/launcher/style.css @@ -1,5 +1,6 @@ #window { -fx-background-color: #131320; + -fx-font-size: 1.25em; } Text, Label { @@ -19,7 +20,7 @@ Text, Label { /* Logo */ .title { -fx-font-weight: bold; - -fx-font-size: 1.35em; + -fx-font-size: 1.5em; -fx-padding: 1; } @@ -47,7 +48,7 @@ Text, Label { /* Settings */ -.res_box Label { +ChoiceBox Label { -fx-fill: #000000; -fx-text-fill: #000000; } @@ -65,4 +66,16 @@ Text, Label { /* Link to project */ Hyperlink:visited { -fx-text-fill: #0095c8; +} + +/**********/ +/* Picker */ +/**********/ + +#picker { + -fx-alignment: top-center; +} + +#picker VBox { + -fx-alignment: top-center; } \ No newline at end of file