add bgmusic

This commit is contained in:
Luca Puderbach 2024-10-13 17:44:13 +02:00
parent 68e252e174
commit f27ec36d2b

View File

@ -7,6 +7,15 @@
package pp.battleship.client; package pp.battleship.client;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.LogManager;
import com.jme3.app.DebugKeysAppState; import com.jme3.app.DebugKeysAppState;
import com.jme3.app.SimpleApplication; import com.jme3.app.SimpleApplication;
import com.jme3.app.StatsAppState; import com.jme3.app.StatsAppState;
@ -20,7 +29,10 @@ import com.jme3.input.controls.MouseButtonTrigger;
import com.jme3.system.AppSettings; import com.jme3.system.AppSettings;
import com.simsilica.lemur.GuiGlobals; import com.simsilica.lemur.GuiGlobals;
import com.simsilica.lemur.style.BaseStyles; import com.simsilica.lemur.style.BaseStyles;
import static pp.battleship.Resources.lookup;
import pp.battleship.client.gui.BattleAppState; import pp.battleship.client.gui.BattleAppState;
import pp.battleship.client.gui.BgMusic;
import pp.battleship.client.gui.EditorAppState; import pp.battleship.client.gui.EditorAppState;
import pp.battleship.client.gui.SeaAppState; import pp.battleship.client.gui.SeaAppState;
import pp.battleship.game.client.BattleshipClient; import pp.battleship.game.client.BattleshipClient;
@ -35,17 +47,6 @@ import pp.dialog.DialogBuilder;
import pp.dialog.DialogManager; import pp.dialog.DialogManager;
import pp.graphics.Draw; import pp.graphics.Draw;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.LogManager;
import static pp.battleship.Resources.lookup;
/** /**
* The main class for the Battleship client application. * The main class for the Battleship client application.
* It manages the initialization, input setup, GUI setup, and game states for the client. * It manages the initialization, input setup, GUI setup, and game states for the client.
@ -268,6 +269,7 @@ public class BattleshipApp extends SimpleApplication implements BattleshipClient
attachGameSound(); attachGameSound();
stateManager.attachAll(new EditorAppState(), new BattleAppState(), new SeaAppState()); stateManager.attachAll(new EditorAppState(), new BattleAppState(), new SeaAppState());
attachBgMusic();
} }
/** /**
@ -279,6 +281,12 @@ public class BattleshipApp extends SimpleApplication implements BattleshipClient
gameSound.setEnabled(GameSound.enabledInPreferences()); gameSound.setEnabled(GameSound.enabledInPreferences());
stateManager.attach(gameSound); stateManager.attach(gameSound);
} }
private void attachBgMusic() {
final BgMusic gameSound = new BgMusic();
gameSound.setEnabled(BgMusic.enabledInPreferences());
stateManager.attach(gameSound);
}
/** /**
* Updates the application state every frame. * Updates the application state every frame.