diff --git a/src/launcher/Config.java b/src/launcher/Config.java index 055e5b8..c1f4517 100644 --- a/src/launcher/Config.java +++ b/src/launcher/Config.java @@ -7,7 +7,7 @@ import org.json.simple.parser.*; public class Config { public int width, height, rounds; - public boolean fullscreen; + public boolean fullscreen, hitboxes; public String stage; public String p1, p2; @@ -37,9 +37,8 @@ public class Config { // print a case of this element stage = (String) settings.get("stage"); - // nb players selection - /* JSONArray nb_players = (JSONArray) jsonO.get("nb_players"); - System.out.println("nb_player : " + nb_players.get(1)); */ + // rounds + rounds = Integer.parseInt((String) settings.get("rounds")); // character selection p1 = (String) settings.get("character1"); @@ -54,6 +53,12 @@ public class Config { fullscreen = true; } else fullscreen = false; + String hb = (String) settings.get("hitboxes"); + if (hb == null) hb = "false"; + if (hb.equals("true")) { + hitboxes = true; + } else hitboxes = false; + // rounds String temprounds = (String) settings.get("rounds"); switch (temprounds) { @@ -63,13 +68,6 @@ public class Config { default: rounds = 1; } - // button selection - /* JSONArray allButton = (JSONArray) jsonO.get("button"); - System.out.println(allButton); - - String up = (String) allButton.get(0); - System.out.println("button for up is : " + up); */ - } catch (FileNotFoundException e) { File f = new File("game.set"); try { @@ -88,7 +86,7 @@ public class Config { } @SuppressWarnings("unchecked") - public void write(int width, int height, int rounds, boolean fullscreen, String character1, String character2, String stage) throws Exception { + public void write(int width, int height, int rounds, boolean fullscreen, boolean hitboxes, String character1, String character2, String stage) throws Exception { JSONObject metafile = new JSONObject(); JSONArray array = new JSONArray(); @@ -98,6 +96,7 @@ public class Config { set.put("height", Integer.toString(height)); set.put("rounds", Integer.toString(rounds)); set.put("fullscreen", Boolean.toString(fullscreen)); + set.put("hitboxes", Boolean.toString(hitboxes)); set.put("character1", character1); set.put("character2", character2); set.put("stage", stage); diff --git a/src/launcher/Launcher.java b/src/launcher/Launcher.java index 7c10e50..947f61e 100644 --- a/src/launcher/Launcher.java +++ b/src/launcher/Launcher.java @@ -75,6 +75,22 @@ public class Launcher extends Application { fs.setSelected(false); } + ChoiceBox cbr = (ChoiceBox) namespace.get("rounds"); + ObservableList nbrounds = FXCollections.observableArrayList("1", "3", "5", "7", "9"); + cbr.setItems(nbrounds); + if (!nbrounds.contains(setter.getRounds())) { + cb.setValue("3"); + } else { + cb.setValue(setter.getRounds()); + } + + CheckBox hb = (CheckBox) namespace.get("hitboxes"); + if (setter.getHitboxes()) { + hb.setSelected(true); + } else { + hb.setSelected(false); + } + VBox v1 = (VBox) namespace.get("p1"); ChoiceBox b1 = (ChoiceBox) v1.getChildren().get(1); VBox v2 = (VBox) namespace.get("p2"); @@ -139,9 +155,14 @@ public class Launcher extends Application { } pointer.arraysettings.put("width", width); pointer.arraysettings.put("height", height); + CheckBox fs = (CheckBox) namespace.get("fullscreen"); pointer.arraysettings.put("fullscreen", fs.isSelected()); - pointer.arraysettings.put("rounds", 3); + CheckBox hb = (CheckBox) namespace.get("hitboxes"); + pointer.arraysettings.put("hitboxes", hb.isSelected()); + + ChoiceBox rnd = (ChoiceBox) namespace.get("rounds"); + pointer.arraysettings.put("rounds", rnd.getValue()); VBox vp1 = (VBox) namespace.get("p1"); ChoiceBox p1 = (ChoiceBox) vp1.getChildren().get(1); diff --git a/src/launcher/Settings.java b/src/launcher/Settings.java index 8c706d7..51ca2b8 100644 --- a/src/launcher/Settings.java +++ b/src/launcher/Settings.java @@ -22,12 +22,13 @@ public class Settings { int height = (Integer) set.get("height"); int rounds = (Integer) set.get("rounds"); boolean fullscreen = (Boolean) set.get("fullscreen"); + boolean hitboxes = (Boolean) set.get("hitboxes"); String character1 = (String) set.get("character1"); String character2 = (String) set.get("character2"); String stage = (String) set.get("stage"); - config.write(width, height, rounds, fullscreen, character1, character2, stage); + config.write(width, height, rounds, fullscreen, hitboxes, character1, character2, stage); } catch (Exception e) { - config.write(800, 600, 3, false, "blue", "blue", "default"); + config.write(800, 600, 3, false, false, "blue", "blue", "default"); System.out.println("Incorrect config file"); } } @@ -40,6 +41,14 @@ public class Settings { return config.fullscreen; } + public boolean getHitboxes() { + return config.hitboxes; + } + + public String getRounds() { + return Integer.toString(config.rounds); + } + public String getChar1() { return config.p1; } diff --git a/src/launcher/launcher.fxml b/src/launcher/launcher.fxml index afd9403..c8a3caa 100644 --- a/src/launcher/launcher.fxml +++ b/src/launcher/launcher.fxml @@ -42,6 +42,14 @@ +