Massive improvements to launcher

Launcher is now capable of closing itself, launching the engine and  has
a saner launcher.fxml
This commit is contained in:
François Autin 2021-06-03 00:47:49 +02:00
parent a9bbde6c46
commit 85b48c40d4
No known key found for this signature in database
GPG Key ID: 24025429AC559B7C
6 changed files with 125 additions and 79 deletions

View File

@ -1,9 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" output="target/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>

View File

@ -16,7 +16,7 @@
<resources>
<resource>
<directory>src/launcher/ui</directory>
<directory>/src/launcher/ui</directory>
</resource>
</resources>

View File

@ -0,0 +1,25 @@
package launcher;
import javafx.fxml.FXML;
public class FXMLController {
public FXMLController() {
}
@FXML
public void launch() {
Launcher.runGame();
}
@FXML
public void settings() {
}
@FXML
public void quit() {
System.exit(0);
}
}

View File

@ -13,25 +13,53 @@ import javafx.application.Application;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.fxml.*;
import engine.Engine;
public class Launcher extends Application {
public static Launcher pointer;
private static Settings setter;
public Launcher() {
pointer = this;
try {
setter = new Settings();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
/*
* 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("ui/launcher.fxml"));
Parent root = FXMLLoader.load(getClass().getResource("/launcher/ui/launcher.fxml"));
Scene main = new Scene(root);
primaryStage.initStyle(StageStyle.UNDECORATED);
//primaryStage.initStyle(StageStyle.UNDECORATED);
primaryStage.setTitle("Boulevard Combattant");
primaryStage.setScene(main);
primaryStage.show();
}
public static void runGame() {
try {
setter.setSettings();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
Engine.main(null);
}
public static void openSettings() {
}
}

View File

@ -1,91 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2015, 2019, Gluon and/or its affiliates.
All rights reserved. Use is subject to license terms.
This file is available and licensed under the following license:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
- Neither the name of Oracle Corporation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<?import javafx.geometry.Rectangle2D?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.layout.Pane?>
<HBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" style="-fx-background-color: #151619;" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1">
<HBox xmlns:fx="http://javafx.com/fxml" stylesheets="/launcher/ui/style.css" fx:id="window"
prefWidth="640" prefHeight="380"
fx:controller="launcher.FXMLController">
<children>
<VBox prefHeight="400.0" prefWidth="157.0">
<VBox fx:id="sidepanel"
prefWidth="120" prefHeight="380">
<children>
<ImageView accessibleText="Logo" fitHeight="240.0" fitWidth="158.0" pickOnBounds="true" preserveRatio="true">
<image>
</image>
</ImageView>
<VBox alignment="BOTTOM_CENTER" prefHeight="263.0" prefWidth="158.0">
<Pane fx:id="logo"
prefWidth="120" prefHeight="120"></Pane>
<VBox fx:id="btn"
prefWidth="120" prefHeight="260">
<children>
<VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0">
<children>
<Button mnemonicParsing="false" text="Run" />
</children>
</VBox>
<Button mnemonicParsing="false" prefHeight="25.0" prefWidth="176.0" text="Settings" />
<Button mnemonicParsing="false" prefHeight="25.0" prefWidth="161.0" style="-fx-background-color: #e80000;" text="X Quit" textFill="WHITE" />
<Button text="Play" fx:id="btn_launch" onAction="#launch"/>
<Button text="Settings" fx:id="btn_settings" onAction="#settings"/>
<Button text="Quit" fx:id="btn_quit" onAction="#quit"/>
</children>
</VBox>
</children>
</VBox>
<VBox prefHeight="400.0" prefWidth="455.0">
<HBox fx:id="picker">
<children>
<HBox alignment="CENTER" prefHeight="266.0" prefWidth="475.0">
<VBox fx:id="p1" styleClass="pane_p">
<children>
<VBox alignment="BOTTOM_CENTER" prefHeight="249.0" prefWidth="233.0">
<children>
<ImageView fitHeight="172.0" fitWidth="211.0" pickOnBounds="true" preserveRatio="true">
<image>
</image>
<viewport>
<Rectangle2D />
</viewport>
</ImageView>
</children>
</VBox>
<VBox alignment="BOTTOM_CENTER" prefHeight="249.0" prefWidth="233.0">
<children>
<ImageView fitHeight="200.0" fitWidth="233.0" pickOnBounds="true" preserveRatio="true">
<image>
</image>
</ImageView>
</children>
</VBox>
<ImageView/>
<ChoiceBox styleClass="char_box" />
<ChoiceBox styleClass="contr_box" />
</children>
</HBox>
<HBox prefHeight="168.0" prefWidth="432.0" />
</children></VBox>
</VBox>
<VBox fx:id="p2" styleClass="pane_p">
<children>
<ImageView/>
<ChoiceBox styleClass="char_box" />
<ChoiceBox styleClass="contr_box" />
</children>
</VBox>
</children>
</HBox>
</children>
</HBox>

27
src/launcher/ui/style.css Normal file
View File

@ -0,0 +1,27 @@
#window {
-fx-background-color: #131320;
}
/* Sidepanel */
#sidepanel {
-fx-background-color: #303050;
}
#logo {
-fx-background-image: "logo.png";
}
#btn {
-fx-alignment: center;
}
#btn > Button {
-fx-cursor: hand;
-fx-padding: 5;
-fx-width: 100;
}
#btn_launch {
-fx-text-alignment: center;
}