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

add(ui): add options scene #14

parent a362af22
No related branches found
No related tags found
4 merge requests!74V1,!73Initial commit,!71Merge DataBase into Development,!4Merge UI into Development
...@@ -82,7 +82,6 @@ public class IntroController implements Initializable { ...@@ -82,7 +82,6 @@ public class IntroController implements Initializable {
} }
private void nextVideo() { private void nextVideo() {
// TODO: look into not disposing mediaPlayer
mediaPlayer.dispose(); mediaPlayer.dispose();
file = new File(fileName + videos[counter + 1]); file = new File(fileName + videos[counter + 1]);
counter++; counter++;
......
...@@ -26,6 +26,10 @@ public class MainMenuController { ...@@ -26,6 +26,10 @@ public class MainMenuController {
switchScene("Statistics"); switchScene("Statistics");
} }
public void optionsScene() {
switchScene("Options");
}
public void exit() { public void exit() {
Stage stage = (Stage) exitButton.getScene().getWindow(); Stage stage = (Stage) exitButton.getScene().getWindow();
stage.close(); stage.close();
......
package de.hdm_stuttgart.battlearena.Controller;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Slider;
import javafx.scene.layout.VBox;
import java.net.URL;
import java.util.ResourceBundle;
public class OptionsController implements Initializable {
@FXML public VBox parent;
@FXML public Slider volumeSlider;
SceneLoader sceneLoader = new SceneLoader();
public int volume;
private boolean setVolume = false;
private void switchScene(String name) {
parent.getChildren().clear();
parent.getChildren().add(sceneLoader.loadScene(name));
}
public void creditScene() {
switchScene("Credits");
}
public void mainMenuScene() {
switchScene("MainMenu");
}
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
// variables keep getting re-initialized after switching scenes. For now not working!!!!!
if (setVolume) {
volumeSlider.setValue(volume);
}
// TODO: use Runtime Database to save volume
volumeSlider.setOnMouseReleased(mouseEvent -> {
setVolume = true;
volume = (int) volumeSlider.getValue();
System.out.println("Volume: " + volume);
});
}
}
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
</Button> </Button>
<Button mnemonicParsing="false" text="Map Creator" VBox.vgrow="ALWAYS" /> <Button mnemonicParsing="false" text="Map Creator" VBox.vgrow="ALWAYS" />
<Button mnemonicParsing="false" onAction="#statisticsScene" text="Statistics" VBox.vgrow="ALWAYS" /> <Button mnemonicParsing="false" onAction="#statisticsScene" text="Statistics" VBox.vgrow="ALWAYS" />
<Button mnemonicParsing="false" onAction="#optionsScene" text="Options" />
<Button fx:id="exitButton" alignment="CENTER" mnemonicParsing="false" onAction="#exit" text="Exit" /> <Button fx:id="exitButton" alignment="CENTER" mnemonicParsing="false" onAction="#exit" text="Exit" />
<Pane VBox.vgrow="ALWAYS" /> <Pane VBox.vgrow="ALWAYS" />
<Pane layoutX="10.0" layoutY="395.0" VBox.vgrow="ALWAYS" /> <Pane layoutX="10.0" layoutY="395.0" VBox.vgrow="ALWAYS" />
......
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Slider?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Text?>
<VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="20.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.OptionsController">
<children>
<HBox alignment="CENTER">
<children>
<VBox alignment="TOP_CENTER" spacing="10.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Volume:" />
<Slider fx:id="volumeSlider" blockIncrement="25.0" majorTickUnit="100.0" minorTickCount="1" prefHeight="14.0" prefWidth="480.0" showTickLabels="true" value="75.0" VBox.vgrow="NEVER" />
</children>
</VBox>
</children>
</HBox>
<Button mnemonicParsing="false" onAction="#creditScene" text="Credits" />
<Button mnemonicParsing="false" onAction="#mainMenuScene" text="Back" />
</children>
</VBox>
...@@ -47,3 +47,14 @@ ...@@ -47,3 +47,14 @@
-fx-background-color: -fx-dark-brown; -fx-background-color: -fx-dark-brown;
-fx-background-insets: 0; -fx-background-insets: 0;
} }
.slider .track {
-fx-background-color: rgba(0, 0, 0, 0.5);
-fx-pref-height: 0.2em;
}
.slider .thumb {
-fx-pref-height: 0.6em;
-fx-pref-width: 0.4em;
-fx-background-color: -fx-brown;
}
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