Add setting for disabling background music

This commit is contained in:
drdev
2014-06-29 03:34:14 +00:00
parent 7c821455aa
commit 93bcca743c
3 changed files with 15 additions and 2 deletions

View File

@@ -179,6 +179,16 @@ public class SettingsPage extends TabPage<SettingsScreen> {
"Enable Sounds",
"Enable sound effects during the game."),
7);
lstSettings.addItem(new BooleanSetting(FPref.UI_ENABLE_MUSIC,
"Enable Music",
"Enable background music during the game.") {
@Override
public void select() {
super.select();
//update background music when this setting changes
Forge.getSoundSystem().changeBackgroundTrack();
}
}, 7);
/*lstSettings.addItem(new BooleanSetting(FPref.UI_ALT_SOUND_SYSTEM,
"Use Alternate Sound System",
"Use the alternate sound system (only use if you have issues with sound not playing or disappearing)."),

View File

@@ -63,6 +63,7 @@ public class ForgePreferences extends PreferencesStore<ForgePreferences.FPref> {
UI_PREFERRED_AVATARS_ONLY ("false"),
UI_TARGETING_OVERLAY ("false"),
UI_ENABLE_SOUNDS ("true"),
UI_ENABLE_MUSIC ("true"),
UI_ALT_SOUND_SYSTEM ("false"),
UI_CURRENT_AI_PROFILE (AiProfileUtil.AI_PROFILE_RANDOM_MATCH),
UI_CLONE_MODE_SOURCE ("false"), /** */

View File

@@ -168,14 +168,16 @@ public class SoundSystem {
changeBackgroundTrack();
}
private void changeBackgroundTrack() {
public void changeBackgroundTrack() {
//ensure old track stopped and disposed of if needed
if (currentTrack != null) {
currentTrack.dispose();
currentTrack = null;
}
if (currentPlaylist == null) { return; }
if (currentPlaylist == null || !FModel.getPreferences().getPrefBoolean(FPref.UI_ENABLE_MUSIC)) {
return;
}
String filename = currentPlaylist.getRandomFilename();
if (filename == null) { return; }