mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-08-06 12:40:17 +02:00
task 10
This commit is contained in:
@@ -272,12 +272,15 @@ public class BattleshipApp extends SimpleApplication implements BattleshipClient
|
||||
stateManager.attachAll(new EditorAppState(), new BattleAppState(), new SeaAppState());
|
||||
}
|
||||
|
||||
private void attachGameMusic() {
|
||||
final GameMusic gameMusic = new GameMusic();
|
||||
gameMusic.setEnabled(GameMusic.enabledInPreferences());
|
||||
stateManager.attach(gameMusic);
|
||||
private void atttachGameMusic() {
|
||||
final GameMusic gameSound = new GameMusic();
|
||||
gameSound.setEnabled(GameMusic.enabledInPreferences());
|
||||
stateManager.attach(gameSound);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Attaches the game sound state and sets its initial enabled state.
|
||||
*
|
||||
|
@@ -12,6 +12,8 @@ import com.jme3.app.state.AbstractAppState;
|
||||
import com.jme3.app.state.AppStateManager;
|
||||
import pp.battleship.game.client.ClientGameLogic;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Abstract class representing a state in the Battleship game.
|
||||
* Extends the AbstractAppState from jMonkeyEngine to manage state behavior.
|
||||
|
@@ -87,7 +87,7 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
||||
* @param name The name of the sound file.
|
||||
* @return The loaded AudioNode.
|
||||
*/
|
||||
private AudioNode loadSound(Application app, String name) {
|
||||
public AudioNode loadSound(Application app, String name) {
|
||||
try {
|
||||
final AudioNode sound = new AudioNode(app.getAssetManager(), name, AudioData.DataType.Buffer);
|
||||
sound.setLooping(false);
|
||||
|
@@ -32,7 +32,7 @@ class Menu extends Dialog {
|
||||
private static final Preferences PREFERENCES = getPreferences(Menu.class);
|
||||
private static final String LAST_PATH = "last.file.path";
|
||||
|
||||
private final VolumeSlider slider;
|
||||
// private final VolumeSlider slider;
|
||||
private final BattleshipApp app;
|
||||
private final Button loadButton = new Button(lookup("menu.map.load"));
|
||||
private final Button saveButton = new Button(lookup("menu.map.save"));
|
||||
@@ -42,13 +42,14 @@ class Menu extends Dialog {
|
||||
*
|
||||
* @param app the BattleshipApp instance
|
||||
*/
|
||||
|
||||
public Menu(BattleshipApp app) {
|
||||
super(app.getDialogManager());
|
||||
this.app = app;
|
||||
addChild(new Label(lookup("battleship.name"), new ElementId("header"))); //NON-NLS
|
||||
addChild(new Checkbox(lookup("menu.sound-enabled"),
|
||||
new StateCheckboxModel(app, GameSound.class)));
|
||||
slider = new VolumeSlider(app.getStateManager().getState(GameMusic.class));
|
||||
// slider = new VolumeSlider(app.getStateManager().getState(GameMusic.class));
|
||||
addChild(loadButton)
|
||||
.addClickCommands(s -> ifTopDialog(this::loadDialog));
|
||||
addChild(saveButton)
|
||||
@@ -61,8 +62,7 @@ class Menu extends Dialog {
|
||||
addChild(new Checkbox(lookup("menu.sound-enabled"), new StateCheckboxModel(app, GameSound.class)));
|
||||
|
||||
addChild(new Checkbox(lookup("menu.background-sound-enabled"), new StateCheckboxModel(app, GameMusic.class)));
|
||||
|
||||
addChild(slider);
|
||||
// addChild(slider);
|
||||
|
||||
}
|
||||
|
||||
@@ -74,11 +74,15 @@ class Menu extends Dialog {
|
||||
loadButton.setEnabled(app.getGameLogic().mayLoadMap());
|
||||
saveButton.setEnabled(app.getGameLogic().maySaveMap());
|
||||
}
|
||||
@Override
|
||||
public void update(float delta){
|
||||
|
||||
/* @Override
|
||||
public void update(float delta) {
|
||||
slider.update();
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* As an escape action, this method closes the menu if it is the top dialog.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user