Skip to content
Snippets Groups Projects
Commit c3e1fb8a authored by Tran Peter's avatar Tran Peter
Browse files

feat(ui): add scene swtich to all scenes, still has duplicated code

parent 6b04e081
No related branches found
No related tags found
4 merge requests!74V1,!73Initial commit,!71Merge DataBase into Development,!4Merge UI into Development
Showing
with 121 additions and 28 deletions
package de.hdm_stuttgart.battlearena.Controller;
public class LocalCreateController {
import javafx.fxml.FXML;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
public class LocalCreateController extends SceneLoader {
@FXML public BorderPane parent;
public void playScene() {
Pane pane = new Pane(loadScene("Play"));
parent.setCenter(pane.getChildren().get(0));
}
}
package de.hdm_stuttgart.battlearena.Controller;
public class MainMenuController {
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
public class MainMenuController extends SceneLoader {
@FXML public BorderPane parent;
@FXML public Button exitButton;
public void playScene() {
Pane pane = new Pane(loadScene("Play"));
// get(0) returns the first item from the getChildren() List
parent.setCenter(pane.getChildren().get(0));
}
public void exit() {
Stage stage = (Stage) exitButton.getScene().getWindow();
stage.close();
}
}
package de.hdm_stuttgart.battlearena.Controller;
public class MultiplayerController {
import javafx.fxml.FXML;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
public class MultiplayerController extends SceneLoader {
@FXML public BorderPane parent;
public void multiplayerCreateScene() {
Pane pane = new Pane(loadScene("MultiplayerCreate"));
parent.setCenter(pane.getChildren().get(0));
}
public void multiplayerJoinScene() {
Pane pane = new Pane(loadScene("MultiplayerJoin"));
parent.setCenter(pane.getChildren().get(0));
}
public void playScene() {
Pane pane = new Pane(loadScene("Play"));
parent.setCenter(pane.getChildren().get(0));
}
}
package de.hdm_stuttgart.battlearena.Controller;
public class MultiplayerCreateController {
import javafx.fxml.FXML;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
public class MultiplayerCreateController extends SceneLoader {
@FXML public BorderPane parent;
public void multiplayerScene() {
Pane pane = new Pane(loadScene("Multiplayer"));
parent.setCenter(pane.getChildren().get(0));
}
}
package de.hdm_stuttgart.battlearena.Controller;
public class MultiplayerJoinController {
import javafx.fxml.FXML;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
public class MultiplayerJoinController extends SceneLoader{
@FXML public BorderPane parent;
public void multiplayerScene() {
Pane pane = new Pane(loadScene("Multiplayer"));
parent.setCenter(pane.getChildren().get(0));
}
}
package de.hdm_stuttgart.battlearena.Controller;
public class PlayController {
import javafx.fxml.FXML;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
public class PlayController extends SceneLoader {
@FXML public BorderPane parent;
public void mainMenuScene() {
Pane pane = new Pane(loadScene("MainMenu"));
parent.setCenter(pane.getChildren().get(0));
}
public void localScene() {
Pane pane = new Pane(loadScene("LocalCreate"));
parent.setCenter(pane.getChildren().get(0));
}
public void multiplayerScene() {
Pane pane = new Pane(loadScene("Multiplayer"));
parent.setCenter(pane.getChildren().get(0));
}
}
......@@ -27,6 +27,9 @@ public class Main extends Application {
stage.setTitle("BattleArena");
stage.setScene(scene);
stage.minHeightProperty().setValue(400);
stage.minWidthProperty().setValue(600);
stage.setMaximized(true);
stage.show();
log.debug("Project started successfully!");
......
......@@ -11,7 +11,7 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Text?>
<BorderPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.LocalCreateController">
<BorderPane fx:id="parent" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.LocalCreateController">
<center>
<VBox alignment="TOP_CENTER" spacing="10.0" BorderPane.alignment="TOP_CENTER">
<children>
......@@ -76,7 +76,7 @@
</children>
</HBox>
<Button mnemonicParsing="false" text="Start" />
<Button mnemonicParsing="false" text="Back">
<Button mnemonicParsing="false" onAction="#playScene" text="Back">
<VBox.margin>
<Insets bottom="50.0" />
</VBox.margin>
......
......@@ -6,19 +6,19 @@
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MainMenuController">
<BorderPane fx:id="parent" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MainMenuController">
<center>
<VBox alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="100.0" spacing="50.0" BorderPane.alignment="CENTER">
<children>
<Pane VBox.vgrow="ALWAYS" />
<Button mnemonicParsing="false" text="Play" VBox.vgrow="ALWAYS">
<Button mnemonicParsing="false" onAction="#playScene" text="Play" VBox.vgrow="ALWAYS">
<VBox.margin>
<Insets top="20.0" />
</VBox.margin>
</Button>
<Button mnemonicParsing="false" text="Map Creator" VBox.vgrow="ALWAYS" />
<Button mnemonicParsing="false" text="Statistics" VBox.vgrow="ALWAYS" />
<Button alignment="CENTER" mnemonicParsing="false" text="Exit" />
<Button fx:id="exitButton" alignment="CENTER" mnemonicParsing="false" onAction="#exit" text="Exit" />
<Pane VBox.vgrow="ALWAYS" />
<Pane layoutX="10.0" layoutY="395.0" VBox.vgrow="ALWAYS" />
</children>
......
......@@ -6,21 +6,21 @@
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.PlayController">
<BorderPane fx:id="parent" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MultiplayerController">
<center>
<VBox alignment="TOP_CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="100.0" spacing="50.0" BorderPane.alignment="CENTER">
<children>
<Pane maxHeight="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS" />
<Button mnemonicParsing="false" text="Create" VBox.vgrow="ALWAYS">
<Button mnemonicParsing="false" onAction="#multiplayerCreateScene" text="Create" VBox.vgrow="ALWAYS">
<VBox.margin>
<Insets top="20.0" />
</VBox.margin>
</Button>
<Button mnemonicParsing="false" text="Join" VBox.vgrow="ALWAYS">
<Button mnemonicParsing="false" onAction="#multiplayerJoinScene" text="Join" VBox.vgrow="ALWAYS">
<VBox.margin>
<Insets bottom="50.0" />
</VBox.margin></Button>
<Button alignment="CENTER" mnemonicParsing="false" text="Back">
<Button alignment="CENTER" mnemonicParsing="false" onAction="#playScene" text="Back">
<VBox.margin>
<Insets />
</VBox.margin></Button>
......
......@@ -11,10 +11,11 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Text?>
<BorderPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MultiplayerCreateController">
<BorderPane fx:id="parent" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MultiplayerCreateController">
<center>
<VBox alignment="TOP_CENTER" prefHeight="200.0" prefWidth="100.0" BorderPane.alignment="CENTER">
<VBox alignment="TOP_CENTER" prefHeight="200.0" prefWidth="100.0" spacing="20.0" BorderPane.alignment="CENTER">
<children>
<Pane VBox.vgrow="ALWAYS" />
<HBox alignment="TOP_CENTER" spacing="20.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Text:" />
......@@ -24,14 +25,12 @@
<Insets top="50.0" />
</VBox.margin>
</HBox>
<Pane prefHeight="200.0" prefWidth="600.0" />
<HBox alignment="TOP_CENTER" layoutX="10.0" layoutY="10.0" maxWidth="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="213.0" spacing="20.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Text:" />
<TextField />
</children>
</HBox>
<Pane prefHeight="200.0" prefWidth="200.0" />
<HBox alignment="TOP_CENTER" layoutX="10.0" layoutY="110.0" spacing="10.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Text:" />
......@@ -39,7 +38,7 @@
<RadioButton mnemonicParsing="false" text="No" />
</children>
</HBox>
<AnchorPane prefHeight="200.0" prefWidth="200.0">
<AnchorPane minHeight="-Infinity" prefHeight="39.0" prefWidth="600.0">
<children>
<VBox alignment="TOP_CENTER" layoutX="250.0" prefHeight="200.0" prefWidth="100.0" AnchorPane.leftAnchor="250.0" AnchorPane.rightAnchor="250.0">
<children>
......@@ -51,8 +50,10 @@
<Insets top="20.0" />
</VBox.margin>
</AnchorPane>
<Button mnemonicParsing="false" text="Button" />
<Button mnemonicParsing="false" text="Button" />
<Button mnemonicParsing="false" text="Start" />
<Button mnemonicParsing="false" onAction="#multiplayerScene" text="Back" />
<Pane layoutX="10.0" layoutY="398.0" VBox.vgrow="ALWAYS" />
<Pane layoutX="10.0" layoutY="393.0" VBox.vgrow="ALWAYS" />
</children>
</VBox>
</center>
......
......@@ -7,7 +7,7 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Text?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.PlayController">
<BorderPane fx:id="parent" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MultiplayerJoinController">
<center>
<VBox alignment="TOP_CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="100.0" spacing="50.0" BorderPane.alignment="CENTER">
<children>
......@@ -17,7 +17,7 @@
<Button mnemonicParsing="false" text="Connect" VBox.vgrow="ALWAYS" />
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="[Error Message]" />
<Pane maxHeight="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS" />
<Button alignment="CENTER" mnemonicParsing="false" text="Back" />
<Button alignment="CENTER" mnemonicParsing="false" onAction="#multiplayerScene" text="Back" />
<Pane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="20.0" VBox.vgrow="ALWAYS" />
</children>
</VBox>
......
......@@ -6,18 +6,18 @@
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.PlayController">
<BorderPane fx:id="parent" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.PlayController">
<center>
<VBox alignment="TOP_CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="100.0" spacing="50.0" BorderPane.alignment="CENTER">
<children>
<Pane VBox.vgrow="ALWAYS" />
<Button mnemonicParsing="false" text="Local" VBox.vgrow="ALWAYS">
<Button mnemonicParsing="false" onAction="#localScene" text="Local" VBox.vgrow="ALWAYS">
<VBox.margin>
<Insets top="20.0" />
</VBox.margin>
</Button>
<Button mnemonicParsing="false" text="Multiplayer" VBox.vgrow="ALWAYS" />
<Button alignment="CENTER" mnemonicParsing="false" text="Back">
<Button mnemonicParsing="false" onAction="#multiplayerScene" text="Multiplayer" VBox.vgrow="ALWAYS" />
<Button alignment="CENTER" mnemonicParsing="false" onAction="#mainMenuScene" text="Back">
<VBox.margin>
<Insets top="50.0" />
</VBox.margin></Button>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment