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

resolve merge conflict

parents e9012e5d 764a4863
No related branches found
No related tags found
5 merge requests!74V1,!73Initial commit,!71Merge DataBase into Development,!54Update: coreMaps.json (added new maps),!49Merge ui into development
......@@ -3,3 +3,15 @@
### Known issues:
- JavaFX Mediaplayer is buggy under Windows 11. Videos can have weird behaviors and sometimes won't load at all
- SQL server is very slow (thanks Oracle)
<br><br>
#### FAQ:
Why is the Game loading so long? <br> - cry about it
Why can't I connect to the Multiplayer? <br> - cry about it
The character is moving too quickly <br> - cry about it
The UI is too small <br> - cry about it
Why doesn't the intro load? <br> - cry about it
\ No newline at end of file
......@@ -3,6 +3,7 @@ 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 de.hdm_stuttgart.battlearena.Model.Sound.MusicPlayer;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
......@@ -20,6 +21,7 @@ public class MainMenuController {
private Button exitButton;
private final SceneLoader sceneLoader = new SceneLoader();
private final Persistence persistence = Persistence.getInstance();
private final MusicPlayer player = MusicPlayer.getInstance();
private void switchScene(String name) {
parent.getChildren().clear();
......@@ -48,6 +50,7 @@ public class MainMenuController {
@FXML
private void exit() throws DatabaseException {
player.getScheduler().shutdown();
persistence.savePlayerStatistics();
persistence.saveSettings();
Stage stage = (Stage) exitButton.getScene().getWindow();
......
......@@ -6,6 +6,8 @@ import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler;
import de.hdm_stuttgart.battlearena.Model.Sound.MusicPlayer;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Rectangle2D;
import javafx.scene.Parent;
......@@ -16,6 +18,7 @@ import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.WindowEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -59,6 +62,8 @@ public class Driver extends Application {
MusicPlayer player = MusicPlayer.getInstance();
player.startGameStateMonitoring();
stage.setOnCloseRequest(windowEvent -> MusicPlayer.getInstance().getScheduler().shutdown());
stage.show();
log.debug("Project started successfully!");
......
......@@ -36,13 +36,15 @@ public class MusicPlayer{
private GameState currentGameState;
private SoundFileManager fileManager = new SoundFileManager();
private ScheduledExecutorService scheduler;
private MusicPlayer(){}
public void startGameStateMonitoring(){
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
scheduler = Executors.newSingleThreadScheduledExecutor();
scheduler.scheduleAtFixedRate(()->{
GameState newGameState = RuntimeInfo.getInstance().getGameState();
if(currentGameState != newGameState){
......@@ -105,6 +107,7 @@ public class MusicPlayer{
public int getVolume(){
return persistence.getSettings().getMusicVolume();
}
public ScheduledExecutorService getScheduler(){return scheduler;}
public static MusicPlayer getInstance(){return musicPlayerSingleton;}
......
package de.hdm_stuttgart.battlearena.Model.Sound;
public enum MusicType {
MENU("src/main/resources/sound/music/menu"),
OPTIONS("src/main/resources/sound/music/options"),
GAME("src/main/resources/sound/music/game");
private String path;
MusicType(String path){
this.path = path;
}
public String getPath(){
return path;
}
}
{
"sfxVolume": 27,
"musicVolume": 11
"sfxVolume": 16,
"musicVolume": 39
}
\ No newline at end of file
import de.hdm_stuttgart.battlearena.Controller.Enum.GameState;
import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence;
import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.RuntimeInfo;
import de.hdm_stuttgart.battlearena.Model.Sound.MusicPlayer;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class MusicPlayerTest {
private static final Logger log = LogManager.getLogger(MusicPlayerTest.class);
RuntimeInfo runtimeInfo;
MusicPlayer musicPlayer;
@BeforeEach
void setup(){
musicPlayer = MusicPlayer.getInstance();
runtimeInfo = RuntimeInfo.getInstance();
}
@Test
void startGameStateMonitoringTest(){
runtimeInfo.setGameState(GameState.MENU);
musicPlayer.startGameStateMonitoring();
}
}
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