Launcher overhaul. Now capable of setting resolution and fullscreen set.
This commit is contained in:
parent
fba6c50de0
commit
76bfe1d56e
@ -16,17 +16,20 @@ import javafx.collections.ObservableList;
|
|||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.ChoiceBox;
|
import javafx.scene.control.ChoiceBox;
|
||||||
|
import javafx.scene.control.CheckBox;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.stage.StageStyle;
|
import javafx.stage.StageStyle;
|
||||||
import javafx.fxml.*;
|
import javafx.fxml.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class Launcher extends Application {
|
public class Launcher extends Application {
|
||||||
|
|
||||||
public static Launcher pointer;
|
public static Launcher pointer;
|
||||||
private static Settings setter;
|
private static Settings setter;
|
||||||
private HashMap<String, Object> arraysettings;
|
private HashMap<String, Object> arraysettings;
|
||||||
|
private static Map<String, Object> namespace;
|
||||||
|
|
||||||
public Launcher() {
|
public Launcher() {
|
||||||
pointer = this;
|
pointer = this;
|
||||||
try {
|
try {
|
||||||
@ -41,15 +44,18 @@ 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
|
* 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 {
|
public void start(Stage primaryStage) throws Exception {
|
||||||
|
|
||||||
Parent root = FXMLLoader.load(getClass().getResource("launcher.fxml"));
|
FXMLLoader loader = new FXMLLoader(getClass().getResource("launcher.fxml"));
|
||||||
|
|
||||||
|
Parent root = loader.load();
|
||||||
|
|
||||||
Scene main = new Scene(root);
|
Scene main = new Scene(root);
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
namespace = loader.getNamespace();
|
||||||
ChoiceBox<String> cb = (ChoiceBox<String>) main.lookup("#resolution");
|
|
||||||
|
|
||||||
|
ChoiceBox<String> cb = (ChoiceBox<String>) namespace.get("resolution");
|
||||||
ObservableList<String> availableres = FXCollections.observableArrayList("640x480", "800x600", "1024x768", "1280x720", "1366x768", "1600x900", "1920x1080");
|
ObservableList<String> availableres = FXCollections.observableArrayList("640x480", "800x600", "1024x768", "1280x720", "1366x768", "1600x900", "1920x1080");
|
||||||
cb.setItems(availableres);
|
cb.setItems(availableres);
|
||||||
if (!availableres.contains(setter.getResolution())) {
|
if (!availableres.contains(setter.getResolution())) {
|
||||||
@ -58,6 +64,15 @@ public class Launcher extends Application {
|
|||||||
cb.setValue(setter.getResolution());
|
cb.setValue(setter.getResolution());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckBox fs = (CheckBox) namespace.get("fullscreen");
|
||||||
|
if(setter.getFullscreen()) {
|
||||||
|
fs.setSelected(true);
|
||||||
|
} else {
|
||||||
|
fs.setSelected(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
primaryStage.initStyle(StageStyle.UNDECORATED);
|
primaryStage.initStyle(StageStyle.UNDECORATED);
|
||||||
primaryStage.setTitle("Boulevard Combattant");
|
primaryStage.setTitle("Boulevard Combattant");
|
||||||
primaryStage.setScene(main);
|
primaryStage.setScene(main);
|
||||||
@ -65,10 +80,57 @@ public class Launcher extends Application {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void runGame() {
|
@FXML
|
||||||
|
public void runGame() {
|
||||||
try {
|
try {
|
||||||
|
int width, height;
|
||||||
|
System.out.println(namespace.size());
|
||||||
|
ChoiceBox<String> cb = (ChoiceBox<String>) namespace.get("resolution");
|
||||||
|
switch (cb.getValue()) {
|
||||||
|
case "640x480":
|
||||||
|
width = 640;
|
||||||
|
height = 480;
|
||||||
|
break;
|
||||||
|
case "800x600":
|
||||||
|
width = 800;
|
||||||
|
height = 600;
|
||||||
|
break;
|
||||||
|
case "1024x768":
|
||||||
|
width = 1024;
|
||||||
|
height = 768;
|
||||||
|
break;
|
||||||
|
case "1280x720":
|
||||||
|
width = 1280;
|
||||||
|
height = 720;
|
||||||
|
break;
|
||||||
|
case "1366x768":
|
||||||
|
width = 1366;
|
||||||
|
height = 768;
|
||||||
|
break;
|
||||||
|
case "1600x900":
|
||||||
|
width = 1600;
|
||||||
|
height = 900;
|
||||||
|
break;
|
||||||
|
case "1920x1080":
|
||||||
|
width = 1920;
|
||||||
|
height = 1080;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
width = 640;
|
||||||
|
height = 480;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
pointer.arraysettings.put("character1", "default");
|
||||||
|
pointer.arraysettings.put("character2", "default");
|
||||||
|
pointer.arraysettings.put("stage", "default");
|
||||||
setter.setSettings();
|
setter.setSettings();
|
||||||
match.main(null);
|
match.main(null);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
@ -77,12 +139,7 @@ public class Launcher extends Application {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void launch() {
|
public void launch() {
|
||||||
Launcher.runGame();
|
this.runGame();
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
public void settings() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -40,4 +40,9 @@ public class Settings {
|
|||||||
public String getResolution() {
|
public String getResolution() {
|
||||||
return "" + Integer.toString(config.width) + "x" + Integer.toString(config.height);
|
return "" + Integer.toString(config.width) + "x" + Integer.toString(config.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getFullscreen() {
|
||||||
|
return config.fullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.Button?>
|
||||||
<?import javafx.scene.control.ChoiceBox?>
|
<?import javafx.scene.control.ChoiceBox?>
|
||||||
|
<?import javafx.scene.control.CheckBox?>
|
||||||
<?import javafx.scene.image.ImageView?>
|
<?import javafx.scene.image.ImageView?>
|
||||||
<?import javafx.scene.image.Image?>
|
<?import javafx.scene.image.Image?>
|
||||||
<?import javafx.scene.layout.HBox?>
|
<?import javafx.scene.layout.HBox?>
|
||||||
@ -36,7 +37,13 @@
|
|||||||
<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"/>
|
||||||
<Label text="Resolution"/>
|
<Label text="Resolution"/>
|
||||||
<ChoiceBox fx:id="resolution"/>
|
<ChoiceBox fx:id="resolution" styleClass="res_box"/>
|
||||||
|
<HBox fx:id="fs_box" styleClass="fs_box">
|
||||||
|
<children>
|
||||||
|
<Label text="Fullscreen"/>
|
||||||
|
<CheckBox fx:id="fullscreen"/>
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
<Button text="Quit" fx:id="btn_quit" onAction="#quit"
|
<Button text="Quit" fx:id="btn_quit" onAction="#quit"
|
||||||
prefWidth="110" prefHeight="15"/>
|
prefWidth="110" prefHeight="15"/>
|
||||||
</children>
|
</children>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#sidepanel {
|
#sidepanel {
|
||||||
-fx-background-color: #303050;
|
-fx-background-color: #303050;
|
||||||
-fx-aligment: center;
|
-fx-alignment: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Logo */
|
/* Logo */
|
||||||
@ -54,7 +54,11 @@ Hyperlink:visited {
|
|||||||
-fx-text-fill: #0095c8;
|
-fx-text-fill: #0095c8;
|
||||||
}
|
}
|
||||||
|
|
||||||
.contr_box {
|
.res_box Label {
|
||||||
-fx-fill: #000000 !important;
|
-fx-fill: #000000 !important;
|
||||||
-fx-text-fill: #000000 !important;
|
-fx-text-fill: #000000 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fs_box {
|
||||||
|
-fx-alignment: center;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user