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

update(Controller): minor fixes

parent 9305b42e
No related branches found
No related tags found
4 merge requests!74V1,!73Initial commit,!71Merge DataBase into Development,!17Merge ui into development
package de.hdm_stuttgart.battlearena.Controller;
import de.hdm_stuttgart.battlearena.Controller.Utilities.SceneLoader;
import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.DatabaseException;
import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
......@@ -17,6 +19,7 @@ public class MainMenuController implements Initializable {
@FXML
private Button exitButton;
private final SceneLoader sceneLoader = new SceneLoader();
private final Persistence persistence = Persistence.getInstance();
private void switchScene(String name) {
parent.getChildren().clear();
......@@ -44,7 +47,9 @@ public class MainMenuController implements Initializable {
}
@FXML
private void exit() {
private void exit() throws DatabaseException {
persistence.savePlayerStatistics();
persistence.saveSettings();
Stage stage = (Stage) exitButton.getScene().getWindow();
stage.close();
}
......
......@@ -56,7 +56,7 @@ public class MapSelectionController implements Initializable {
@FXML
private void gameScene() {
try {
// RuntimeInfo.getInstance().setGameMap(selectedMap, true);
RuntimeInfo.getInstance().setGameMap(coreMaps.get(selectedMap));
MusicPlayerSingleton.getInstance().getMediaPlayer().dispose();
parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/GameScene.fxml"))));
} catch (IOException e) {
......
......@@ -47,7 +47,7 @@
<Insets top="20.0" />
</VBox.margin>
</AnchorPane>
<Button mnemonicParsing="false" text="Start" />
<Button mnemonicParsing="false" onAction="#start" text="Start" />
<Button mnemonicParsing="false" onAction="#backButton" text="Back" />
<Pane VBox.vgrow="ALWAYS" />
<Pane VBox.vgrow="ALWAYS" />
......
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