partially improved launcher functionnality
This commit is contained in:
parent
e645f66dc8
commit
e36955d948
@ -7,7 +7,7 @@ import org.json.simple.parser.*;
|
|||||||
public class Config {
|
public class Config {
|
||||||
|
|
||||||
public int width, height, rounds;
|
public int width, height, rounds;
|
||||||
public boolean fullscreen;
|
public boolean fullscreen, hitboxes;
|
||||||
public String stage;
|
public String stage;
|
||||||
public String p1, p2;
|
public String p1, p2;
|
||||||
|
|
||||||
@ -37,9 +37,8 @@ public class Config {
|
|||||||
// print a case of this element
|
// print a case of this element
|
||||||
stage = (String) settings.get("stage");
|
stage = (String) settings.get("stage");
|
||||||
|
|
||||||
// nb players selection
|
// rounds
|
||||||
/* JSONArray nb_players = (JSONArray) jsonO.get("nb_players");
|
rounds = Integer.parseInt((String) settings.get("rounds"));
|
||||||
System.out.println("nb_player : " + nb_players.get(1)); */
|
|
||||||
|
|
||||||
// character selection
|
// character selection
|
||||||
p1 = (String) settings.get("character1");
|
p1 = (String) settings.get("character1");
|
||||||
@ -54,6 +53,12 @@ public class Config {
|
|||||||
fullscreen = true;
|
fullscreen = true;
|
||||||
} else fullscreen = false;
|
} else fullscreen = false;
|
||||||
|
|
||||||
|
String hb = (String) settings.get("hitboxes");
|
||||||
|
if (hb == null) hb = "false";
|
||||||
|
if (hb.equals("true")) {
|
||||||
|
hitboxes = true;
|
||||||
|
} else hitboxes = false;
|
||||||
|
|
||||||
// rounds
|
// rounds
|
||||||
String temprounds = (String) settings.get("rounds");
|
String temprounds = (String) settings.get("rounds");
|
||||||
switch (temprounds) {
|
switch (temprounds) {
|
||||||
@ -63,13 +68,6 @@ public class Config {
|
|||||||
default: rounds = 1;
|
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) {
|
} catch (FileNotFoundException e) {
|
||||||
File f = new File("game.set");
|
File f = new File("game.set");
|
||||||
try {
|
try {
|
||||||
@ -88,7 +86,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@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();
|
JSONObject metafile = new JSONObject();
|
||||||
JSONArray array = new JSONArray();
|
JSONArray array = new JSONArray();
|
||||||
@ -98,6 +96,7 @@ public class Config {
|
|||||||
set.put("height", Integer.toString(height));
|
set.put("height", Integer.toString(height));
|
||||||
set.put("rounds", Integer.toString(rounds));
|
set.put("rounds", Integer.toString(rounds));
|
||||||
set.put("fullscreen", Boolean.toString(fullscreen));
|
set.put("fullscreen", Boolean.toString(fullscreen));
|
||||||
|
set.put("hitboxes", Boolean.toString(hitboxes));
|
||||||
set.put("character1", character1);
|
set.put("character1", character1);
|
||||||
set.put("character2", character2);
|
set.put("character2", character2);
|
||||||
set.put("stage", stage);
|
set.put("stage", stage);
|
||||||
|
@ -75,6 +75,22 @@ public class Launcher extends Application {
|
|||||||
fs.setSelected(false);
|
fs.setSelected(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChoiceBox<String> cbr = (ChoiceBox<String>) namespace.get("rounds");
|
||||||
|
ObservableList<String> 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");
|
VBox v1 = (VBox) namespace.get("p1");
|
||||||
ChoiceBox<String> b1 = (ChoiceBox<String>) v1.getChildren().get(1);
|
ChoiceBox<String> b1 = (ChoiceBox<String>) v1.getChildren().get(1);
|
||||||
VBox v2 = (VBox) namespace.get("p2");
|
VBox v2 = (VBox) namespace.get("p2");
|
||||||
@ -139,9 +155,14 @@ public class Launcher extends Application {
|
|||||||
}
|
}
|
||||||
pointer.arraysettings.put("width", width);
|
pointer.arraysettings.put("width", width);
|
||||||
pointer.arraysettings.put("height", height);
|
pointer.arraysettings.put("height", height);
|
||||||
|
|
||||||
CheckBox fs = (CheckBox) namespace.get("fullscreen");
|
CheckBox fs = (CheckBox) namespace.get("fullscreen");
|
||||||
pointer.arraysettings.put("fullscreen", fs.isSelected());
|
pointer.arraysettings.put("fullscreen", fs.isSelected());
|
||||||
pointer.arraysettings.put("rounds", 3);
|
CheckBox hb = (CheckBox) namespace.get("hitboxes");
|
||||||
|
pointer.arraysettings.put("hitboxes", hb.isSelected());
|
||||||
|
|
||||||
|
ChoiceBox<String> rnd = (ChoiceBox<String>) namespace.get("rounds");
|
||||||
|
pointer.arraysettings.put("rounds", rnd.getValue());
|
||||||
|
|
||||||
VBox vp1 = (VBox) namespace.get("p1");
|
VBox vp1 = (VBox) namespace.get("p1");
|
||||||
ChoiceBox<String> p1 = (ChoiceBox<String>) vp1.getChildren().get(1);
|
ChoiceBox<String> p1 = (ChoiceBox<String>) vp1.getChildren().get(1);
|
||||||
|
@ -22,12 +22,13 @@ public class Settings {
|
|||||||
int height = (Integer) set.get("height");
|
int height = (Integer) set.get("height");
|
||||||
int rounds = (Integer) set.get("rounds");
|
int rounds = (Integer) set.get("rounds");
|
||||||
boolean fullscreen = (Boolean) set.get("fullscreen");
|
boolean fullscreen = (Boolean) set.get("fullscreen");
|
||||||
|
boolean hitboxes = (Boolean) set.get("hitboxes");
|
||||||
String character1 = (String) set.get("character1");
|
String character1 = (String) set.get("character1");
|
||||||
String character2 = (String) set.get("character2");
|
String character2 = (String) set.get("character2");
|
||||||
String stage = (String) set.get("stage");
|
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) {
|
} 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");
|
System.out.println("Incorrect config file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -40,6 +41,14 @@ public class Settings {
|
|||||||
return config.fullscreen;
|
return config.fullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getHitboxes() {
|
||||||
|
return config.hitboxes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRounds() {
|
||||||
|
return Integer.toString(config.rounds);
|
||||||
|
}
|
||||||
|
|
||||||
public String getChar1() {
|
public String getChar1() {
|
||||||
return config.p1;
|
return config.p1;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,14 @@
|
|||||||
<CheckBox fx:id="fullscreen"/>
|
<CheckBox fx:id="fullscreen"/>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
|
<Label text="Rounds"/>
|
||||||
|
<ChoiceBox fx:id="rounds" styleClass="res_box"/>
|
||||||
|
<HBox fx:id="hb_box" styleClass="fs_box">
|
||||||
|
<children>
|
||||||
|
<Label text="Hitboxes "/>
|
||||||
|
<CheckBox fx:id="hitboxes"/>
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
<Button text="Play" fx:id="btn_launch" onAction="#launch"
|
<Button text="Play" fx:id="btn_launch" onAction="#launch"
|
||||||
prefWidth="110" prefHeight="15"/>
|
prefWidth="110" prefHeight="15"/>
|
||||||
<Button text="Quit" fx:id="btn_quit" onAction="#quit"
|
<Button text="Quit" fx:id="btn_quit" onAction="#quit"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user