mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
[Mobile] Sound/Music Adjustment
This commit is contained in:
@@ -58,7 +58,7 @@ public class AudioClip implements IAudioClip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void play() {
|
public final void play(float value) {
|
||||||
if (clips.stream().anyMatch(ClipWrapper::isRunning)) {
|
if (clips.stream().anyMatch(ClipWrapper::isRunning)) {
|
||||||
// introduce small delay to make a batch sounds more granular,
|
// introduce small delay to make a batch sounds more granular,
|
||||||
// e.g. when you auto-tap 4 lands the 4 tap sounds should
|
// e.g. when you auto-tap 4 lands the 4 tap sounds should
|
||||||
|
|||||||
@@ -114,4 +114,9 @@ public class AudioMusic implements IAudioMusic {
|
|||||||
close();
|
close();
|
||||||
canResume = false;
|
canResume = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setVolume(float value) {
|
||||||
|
//todo
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ public class Forge implements ApplicationListener {
|
|||||||
public static int androidVersion = 0;
|
public static int androidVersion = 0;
|
||||||
public static boolean autoCache = false;
|
public static boolean autoCache = false;
|
||||||
public static int lastButtonIndex = 0;
|
public static int lastButtonIndex = 0;
|
||||||
|
public static float clipVol = 1f;
|
||||||
|
public static float musicVol = 1f;
|
||||||
|
|
||||||
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM, boolean isTablet, int AndroidAPI, String AndroidRelease, String deviceName) {
|
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM, boolean isTablet, int AndroidAPI, String AndroidRelease, String deviceName) {
|
||||||
if (GuiBase.getInterface() == null) {
|
if (GuiBase.getInterface() == null) {
|
||||||
@@ -118,6 +120,9 @@ public class Forge implements ApplicationListener {
|
|||||||
destroyThis = true; //Prevent back()
|
destroyThis = true; //Prevent back()
|
||||||
ForgePreferences prefs = new ForgePreferences();
|
ForgePreferences prefs = new ForgePreferences();
|
||||||
|
|
||||||
|
clipVol = prefs.getPrefInt(FPref.UI_VOL_SOUNDS)/100f;
|
||||||
|
musicVol = prefs.getPrefInt(FPref.UI_VOL_SOUNDS)/100f;
|
||||||
|
|
||||||
String skinName;
|
String skinName;
|
||||||
if (FileUtil.doesFileExist(ForgeConstants.MAIN_PREFS_FILE)) {
|
if (FileUtil.doesFileExist(ForgeConstants.MAIN_PREFS_FILE)) {
|
||||||
skinName = prefs.getPref(FPref.UI_SKIN);
|
skinName = prefs.getPref(FPref.UI_SKIN);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package forge.animation;
|
package forge.animation;
|
||||||
|
|
||||||
|
import forge.Forge;
|
||||||
import forge.Graphics;
|
import forge.Graphics;
|
||||||
import forge.properties.ForgeConstants;
|
import forge.properties.ForgeConstants;
|
||||||
import forge.sound.AudioClip;
|
import forge.sound.AudioClip;
|
||||||
@@ -23,7 +24,7 @@ public enum AbilityEffect {
|
|||||||
if (soundClip == null) {
|
if (soundClip == null) {
|
||||||
soundClip = AudioClip.createClip(ForgeConstants.EFFECTS_DIR + wav);
|
soundClip = AudioClip.createClip(ForgeConstants.EFFECTS_DIR + wav);
|
||||||
}
|
}
|
||||||
soundClip.play();
|
soundClip.play(Forge.clipVol);
|
||||||
animation.start();
|
animation.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -438,20 +438,58 @@ public class SettingsPage extends TabPage<SettingsScreen> {
|
|||||||
localizer.getMessage("nlVibrateAfterLongPress")),
|
localizer.getMessage("nlVibrateAfterLongPress")),
|
||||||
6);
|
6);
|
||||||
//Sound Options
|
//Sound Options
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.UI_ENABLE_SOUNDS,
|
if(GuiBase.getInterface().isLibgdxPort()) {
|
||||||
localizer.getMessage("cbEnableSounds"),
|
lstSettings.addItem(new CustomSelectSetting(FPref.UI_VOL_SOUNDS,
|
||||||
localizer.getMessage("nlEnableSounds")),
|
localizer.getMessage("cbAdjustSoundsVolume"),
|
||||||
7);
|
localizer.getMessage("nlAdjustSoundsVolume"),
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.UI_ENABLE_MUSIC,
|
new String[]{"0", "25", "50", "75", "100"}) {
|
||||||
localizer.getMessage("cbEnableMusic"),
|
@Override
|
||||||
localizer.getMessage("nlEnableMusic")) {
|
public void valueChanged(String newValue) {
|
||||||
@Override
|
super.valueChanged(newValue);
|
||||||
public void select() {
|
try {
|
||||||
super.select();
|
int val = Integer.parseInt(newValue);
|
||||||
//update background music when this setting changes
|
Forge.clipVol = val/100f;
|
||||||
SoundSystem.instance.changeBackgroundTrack();
|
|
||||||
}
|
}
|
||||||
},7);
|
catch (Exception e) {
|
||||||
|
Forge.clipVol = 1f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 7);
|
||||||
|
lstSettings.addItem(new CustomSelectSetting(FPref.UI_VOL_MUSIC,
|
||||||
|
localizer.getMessage("cbAdjustMusicVolume"),
|
||||||
|
localizer.getMessage("nlAdjustMusicVolume"),
|
||||||
|
new String[]{"0", "25", "50", "75", "100"}) {
|
||||||
|
@Override
|
||||||
|
public void valueChanged(String newValue) {
|
||||||
|
super.valueChanged(newValue);
|
||||||
|
try {
|
||||||
|
int val = Integer.parseInt(newValue);
|
||||||
|
Forge.musicVol = val/100f;
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
Forge.musicVol = 1f;
|
||||||
|
}
|
||||||
|
//update background music when this setting changes
|
||||||
|
SoundSystem.instance.changeBackgroundTrack();
|
||||||
|
SoundSystem.instance.adjustVolume(Forge.musicVol);
|
||||||
|
}
|
||||||
|
}, 7);
|
||||||
|
} else {
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.UI_ENABLE_SOUNDS,
|
||||||
|
localizer.getMessage("cbEnableSounds"),
|
||||||
|
localizer.getMessage("nlEnableSounds")),
|
||||||
|
7);
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.UI_ENABLE_MUSIC,
|
||||||
|
localizer.getMessage("cbEnableMusic"),
|
||||||
|
localizer.getMessage("nlEnableMusic")) {
|
||||||
|
@Override
|
||||||
|
public void select() {
|
||||||
|
super.select();
|
||||||
|
//update background music when this setting changes
|
||||||
|
SoundSystem.instance.changeBackgroundTrack();
|
||||||
|
}
|
||||||
|
},7);
|
||||||
|
}
|
||||||
/*lstSettings.addItem(new BooleanSetting(FPref.UI_ALT_SOUND_SYSTEM,
|
/*lstSettings.addItem(new BooleanSetting(FPref.UI_ALT_SOUND_SYSTEM,
|
||||||
"Use Alternate Sound System",
|
"Use Alternate Sound System",
|
||||||
"Use the alternate sound system (only use if you have issues with sound not playing or disappearing)."),
|
"Use the alternate sound system (only use if you have issues with sound not playing or disappearing)."),
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class AudioClip implements IAudioClip {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void play() {
|
public final void play(float value) {
|
||||||
if (clip == null) {
|
if (clip == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ public class AudioClip implements IAudioClip {
|
|||||||
catch (InterruptedException ex) {
|
catch (InterruptedException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
clip.play();
|
clip.play(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void loop() {
|
public final void loop() {
|
||||||
|
|||||||
@@ -40,4 +40,9 @@ public class AudioMusic implements IAudioMusic {
|
|||||||
stop();
|
stop();
|
||||||
music.dispose();
|
music.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setVolume(float value) {
|
||||||
|
music.setVolume(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ cbRandomFoil=zufällige Foil-Karten
|
|||||||
cbRandomArtInPools=zufällige Kartenbilder in erzeugten Kartensammlungen
|
cbRandomArtInPools=zufällige Kartenbilder in erzeugten Kartensammlungen
|
||||||
cbEnableSounds=Ton aktiviert
|
cbEnableSounds=Ton aktiviert
|
||||||
cbEnableMusic=Musik aktiviert
|
cbEnableMusic=Musik aktiviert
|
||||||
|
cbAdjustSoundsVolume=Adjust Sound Volume
|
||||||
|
cbAdjustMusicVolume=Adjust Music Volume
|
||||||
cbAltSoundSystem=Nutze alternatives Sound-System
|
cbAltSoundSystem=Nutze alternatives Sound-System
|
||||||
cbSROptimize=Optimiere Interface für Screenreader
|
cbSROptimize=Optimiere Interface für Screenreader
|
||||||
cbUiForTouchScreen=Verbessere Oberfläche für Touchscreens
|
cbUiForTouchScreen=Verbessere Oberfläche für Touchscreens
|
||||||
@@ -182,6 +184,8 @@ nlDisplayCurrentCardColors=Zeigt eine Übersicht der aktuellen Farbe der Karten
|
|||||||
SoundOptions=Sound-Optionen
|
SoundOptions=Sound-Optionen
|
||||||
nlEnableSounds=Geräusche während des Spiels
|
nlEnableSounds=Geräusche während des Spiels
|
||||||
nlEnableMusic=Hintergrundmusik während des Spiels
|
nlEnableMusic=Hintergrundmusik während des Spiels
|
||||||
|
nlAdjustSoundsVolume=Adjust sound effects volume during the game
|
||||||
|
nlAdjustMusicVolume=Adjust background music during the game
|
||||||
nlAltSoundSystem=Nutze alternatives Sound-System (nur nutzen, wenn es Probleme mit fehlenden Geräuschen gibt)
|
nlAltSoundSystem=Nutze alternatives Sound-System (nur nutzen, wenn es Probleme mit fehlenden Geräuschen gibt)
|
||||||
nlSrOptimize=Setze verschiedene Optionen, um Forge besser für Screenreader lesbar zu machen
|
nlSrOptimize=Setze verschiedene Optionen, um Forge besser für Screenreader lesbar zu machen
|
||||||
KeyboardShortcuts=Tastenkombinationen
|
KeyboardShortcuts=Tastenkombinationen
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ cbRandomFoil=Random Foil
|
|||||||
cbRandomArtInPools=Randomize Card Art in Generated Card Pools
|
cbRandomArtInPools=Randomize Card Art in Generated Card Pools
|
||||||
cbEnableSounds=Enable Sounds
|
cbEnableSounds=Enable Sounds
|
||||||
cbEnableMusic=Enable Music
|
cbEnableMusic=Enable Music
|
||||||
|
cbAdjustSoundsVolume=Adjust Sound Volume
|
||||||
|
cbAdjustMusicVolume=Adjust Music Volume
|
||||||
cbAltSoundSystem=Use Alternate Sound System
|
cbAltSoundSystem=Use Alternate Sound System
|
||||||
cbSROptimize=Optimize UI for screen readers
|
cbSROptimize=Optimize UI for screen readers
|
||||||
cbUiForTouchScreen=Enhance UI for Touchscreens
|
cbUiForTouchScreen=Enhance UI for Touchscreens
|
||||||
@@ -182,6 +184,8 @@ nlDisplayCurrentCardColors=Displays the breakdown of the current color of cards
|
|||||||
SoundOptions=Sound Options
|
SoundOptions=Sound Options
|
||||||
nlEnableSounds=Enable sound effects during the game
|
nlEnableSounds=Enable sound effects during the game
|
||||||
nlEnableMusic=Enable background music during the game
|
nlEnableMusic=Enable background music during the game
|
||||||
|
nlAdjustSoundsVolume=Adjust sound effects volume during the game
|
||||||
|
nlAdjustMusicVolume=Adjust background music during the game
|
||||||
nlAltSoundSystem=Use the alternate sound system (only use if you have issues with sound not playing or disappearing)
|
nlAltSoundSystem=Use the alternate sound system (only use if you have issues with sound not playing or disappearing)
|
||||||
nlSrOptimize=Set various options to make FOrge work better with screen readers
|
nlSrOptimize=Set various options to make FOrge work better with screen readers
|
||||||
KeyboardShortcuts=Keyboard Shortcuts
|
KeyboardShortcuts=Keyboard Shortcuts
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ cbRandomFoil=Foil Aleatorio
|
|||||||
cbRandomArtInPools=Aleatorizar Arte de la Carta en los pools que se generen
|
cbRandomArtInPools=Aleatorizar Arte de la Carta en los pools que se generen
|
||||||
cbEnableSounds=Activar sonidos
|
cbEnableSounds=Activar sonidos
|
||||||
cbEnableMusic=Activar música
|
cbEnableMusic=Activar música
|
||||||
|
cbAdjustSoundsVolume=Adjust Sound Volume
|
||||||
|
cbAdjustMusicVolume=Adjust Music Volume
|
||||||
cbAltSoundSystem=Utilizar el sistema de sonido alternativo
|
cbAltSoundSystem=Utilizar el sistema de sonido alternativo
|
||||||
cbSROptimize=Optimizar la interfaz de usuario para los lectores de pantalla
|
cbSROptimize=Optimizar la interfaz de usuario para los lectores de pantalla
|
||||||
cbUiForTouchScreen=Mejorar la interfaz de usuario para pantallas táctiles
|
cbUiForTouchScreen=Mejorar la interfaz de usuario para pantallas táctiles
|
||||||
@@ -182,6 +184,8 @@ nlDisplayCurrentCardColors=Muestra el color actual de las cartas en el panel de
|
|||||||
SoundOptions=Opciones de Sonido
|
SoundOptions=Opciones de Sonido
|
||||||
nlEnableSounds=Habilita los efectos de sonido durante el juego
|
nlEnableSounds=Habilita los efectos de sonido durante el juego
|
||||||
nlEnableMusic=Habilita la música de fondo durante el juego
|
nlEnableMusic=Habilita la música de fondo durante el juego
|
||||||
|
nlAdjustSoundsVolume=Adjust sound effects volume during the game
|
||||||
|
nlAdjustMusicVolume=Adjust background music during the game
|
||||||
nlAltSoundSystem=Use el sistema de sonido alternativo (solo use si tiene problemas con el sonido que no se reproduce o desaparece)
|
nlAltSoundSystem=Use el sistema de sonido alternativo (solo use si tiene problemas con el sonido que no se reproduce o desaparece)
|
||||||
nlSrOptimize=Establecer varias opciones para que Forge funcione mejor con los lectores de pantalla
|
nlSrOptimize=Establecer varias opciones para que Forge funcione mejor con los lectores de pantalla
|
||||||
KeyboardShortcuts=Atajos de teclado
|
KeyboardShortcuts=Atajos de teclado
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ cbRandomFoil=Lamina casuale
|
|||||||
cbRandomArtInPools=Randomizza l''arte della carta nei pool di carte generati
|
cbRandomArtInPools=Randomizza l''arte della carta nei pool di carte generati
|
||||||
cbEnableSounds=Abilita suoni
|
cbEnableSounds=Abilita suoni
|
||||||
cbEnableMusic=Abilita musica
|
cbEnableMusic=Abilita musica
|
||||||
|
cbAdjustSoundsVolume=Adjust Sound Volume
|
||||||
|
cbAdjustMusicVolume=Adjust Music Volume
|
||||||
cbAltSoundSystem=Usa un sistema audio alternativo
|
cbAltSoundSystem=Usa un sistema audio alternativo
|
||||||
cbSROptimize=Optimize UI for screen readers
|
cbSROptimize=Optimize UI for screen readers
|
||||||
cbUiForTouchScreen=Migliora l''interfaccia utente per i touchscreen
|
cbUiForTouchScreen=Migliora l''interfaccia utente per i touchscreen
|
||||||
@@ -182,6 +184,8 @@ nlDisplayCurrentCardColors=Visualizza la suddivisione del colore corrente delle
|
|||||||
SoundOptions=Opzioni audio
|
SoundOptions=Opzioni audio
|
||||||
nlEnableSounds=Abilita gli effetti sonori durante il gioco
|
nlEnableSounds=Abilita gli effetti sonori durante il gioco
|
||||||
nlEnableMusic=Abilita la musica di sottofondo durante il gioco
|
nlEnableMusic=Abilita la musica di sottofondo durante il gioco
|
||||||
|
nlAdjustSoundsVolume=Adjust sound effects volume during the game
|
||||||
|
nlAdjustMusicVolume=Adjust background music during the game
|
||||||
nlAltSoundSystem=Utilizza il sistema audio alternativo (utilizza solo se hai problemi con l''audio che non viene riprodotto o che scompare)
|
nlAltSoundSystem=Utilizza il sistema audio alternativo (utilizza solo se hai problemi con l''audio che non viene riprodotto o che scompare)
|
||||||
nlSrOptimize=Set various options to make FOrge work better with screen readers
|
nlSrOptimize=Set various options to make FOrge work better with screen readers
|
||||||
KeyboardShortcuts=Tasti rapidi
|
KeyboardShortcuts=Tasti rapidi
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ cbRandomFoil=随机闪卡
|
|||||||
cbRandomArtInPools=在生成的卡池中随机加入闪卡
|
cbRandomArtInPools=在生成的卡池中随机加入闪卡
|
||||||
cbEnableSounds=启用音效
|
cbEnableSounds=启用音效
|
||||||
cbEnableMusic=启用背景音乐
|
cbEnableMusic=启用背景音乐
|
||||||
|
cbAdjustSoundsVolume=Adjust Sound Volume
|
||||||
|
cbAdjustMusicVolume=Adjust Music Volume
|
||||||
cbAltSoundSystem=使用备用音效系统
|
cbAltSoundSystem=使用备用音效系统
|
||||||
cbUiForTouchScreen=触摸屏UI增强
|
cbUiForTouchScreen=触摸屏UI增强
|
||||||
cbSROptimize=为屏幕阅读器启用UI优化
|
cbSROptimize=为屏幕阅读器启用UI优化
|
||||||
@@ -182,6 +184,8 @@ nlDisplayCurrentCardColors=在卡牌详情窗格中显示当前牌的颜色
|
|||||||
SoundOptions=声音选项
|
SoundOptions=声音选项
|
||||||
nlEnableSounds=在游戏中启用声音效果
|
nlEnableSounds=在游戏中启用声音效果
|
||||||
nlEnableMusic=在游戏中启用背景音乐
|
nlEnableMusic=在游戏中启用背景音乐
|
||||||
|
nlAdjustSoundsVolume=Adjust sound effects volume during the game
|
||||||
|
nlAdjustMusicVolume=Adjust background music during the game
|
||||||
nlAltSoundSystem=使用备用音效系统(仅在声音消失的情况使用)
|
nlAltSoundSystem=使用备用音效系统(仅在声音消失的情况使用)
|
||||||
nlSrOptimize=使屏幕阅读器能更好的在forge上使用
|
nlSrOptimize=使屏幕阅读器能更好的在forge上使用
|
||||||
KeyboardShortcuts=键盘快捷键
|
KeyboardShortcuts=键盘快捷键
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ public class ForgePreferences extends PreferencesStore<ForgePreferences.FPref> {
|
|||||||
UI_TIMED_TARGETING_OVERLAY_UPDATES ("true"),
|
UI_TIMED_TARGETING_OVERLAY_UPDATES ("true"),
|
||||||
UI_ENABLE_SOUNDS ("true"),
|
UI_ENABLE_SOUNDS ("true"),
|
||||||
UI_ENABLE_MUSIC ("true"),
|
UI_ENABLE_MUSIC ("true"),
|
||||||
|
UI_VOL_SOUNDS ("100"),
|
||||||
|
UI_VOL_MUSIC ("100"),
|
||||||
UI_ALT_SOUND_SYSTEM ("false"),
|
UI_ALT_SOUND_SYSTEM ("false"),
|
||||||
UI_CURRENT_AI_PROFILE ("Default"),
|
UI_CURRENT_AI_PROFILE ("Default"),
|
||||||
UI_CLONE_MODE_SOURCE ("false"),
|
UI_CLONE_MODE_SOURCE ("false"),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package forge.sound;
|
package forge.sound;
|
||||||
|
|
||||||
public interface IAudioClip {
|
public interface IAudioClip {
|
||||||
void play();
|
void play(float value);
|
||||||
boolean isDone();
|
boolean isDone();
|
||||||
void stop();
|
void stop();
|
||||||
void loop();
|
void loop();
|
||||||
|
|||||||
@@ -6,4 +6,5 @@ public interface IAudioMusic {
|
|||||||
void resume();
|
void resume();
|
||||||
void stop();
|
void stop();
|
||||||
void dispose();
|
void dispose();
|
||||||
|
void setVolume(float value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ package forge.sound;
|
|||||||
public class NoSoundClip implements IAudioClip {
|
public class NoSoundClip implements IAudioClip {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void play() { }
|
public void play(float value) { }
|
||||||
@Override
|
@Override
|
||||||
public boolean isDone() { return false; }
|
public boolean isDone() { return false; }
|
||||||
|
|
||||||
|
|||||||
@@ -43,8 +43,14 @@ public class SoundSystem {
|
|||||||
* was unavailable or failed to load.
|
* was unavailable or failed to load.
|
||||||
*/
|
*/
|
||||||
protected IAudioClip fetchResource(final SoundEffectType type) {
|
protected IAudioClip fetchResource(final SoundEffectType type) {
|
||||||
if (!FModel.getPreferences().getPrefBoolean(FPref.UI_ENABLE_SOUNDS)) {
|
if (GuiBase.getInterface().isLibgdxPort()) {
|
||||||
return emptySound;
|
if (FModel.getPreferences().getPrefInt(FPref.UI_VOL_SOUNDS)<1) {
|
||||||
|
return emptySound;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!FModel.getPreferences().getPrefBoolean(FPref.UI_ENABLE_SOUNDS)) {
|
||||||
|
return emptySound;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IAudioClip clip = loadedClips.get(type);
|
IAudioClip clip = loadedClips.get(type);
|
||||||
@@ -66,8 +72,14 @@ public class SoundSystem {
|
|||||||
* was unavailable or failed to load.
|
* was unavailable or failed to load.
|
||||||
*/
|
*/
|
||||||
protected IAudioClip fetchResource(final String fileName) {
|
protected IAudioClip fetchResource(final String fileName) {
|
||||||
if (!FModel.getPreferences().getPrefBoolean(FPref.UI_ENABLE_SOUNDS)) {
|
if (GuiBase.getInterface().isLibgdxPort()) {
|
||||||
return emptySound;
|
if (FModel.getPreferences().getPrefInt(FPref.UI_VOL_SOUNDS)<1) {
|
||||||
|
return emptySound;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!FModel.getPreferences().getPrefBoolean(FPref.UI_ENABLE_SOUNDS)) {
|
||||||
|
return emptySound;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IAudioClip clip = loadedScriptClips.get(fileName);
|
IAudioClip clip = loadedScriptClips.get(fileName);
|
||||||
@@ -101,7 +113,7 @@ public class SoundSystem {
|
|||||||
else {
|
else {
|
||||||
final IAudioClip snd = fetchResource(resourceFileName);
|
final IAudioClip snd = fetchResource(resourceFileName);
|
||||||
if (!isSynchronized || snd.isDone()) {
|
if (!isSynchronized || snd.isDone()) {
|
||||||
snd.play();
|
snd.play(FModel.getPreferences().getPrefInt(FPref.UI_VOL_SOUNDS)/100f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +128,7 @@ public class SoundSystem {
|
|||||||
else {
|
else {
|
||||||
final IAudioClip snd = fetchResource(type);
|
final IAudioClip snd = fetchResource(type);
|
||||||
if (!isSynchronized || snd.isDone()) {
|
if (!isSynchronized || snd.isDone()) {
|
||||||
snd.play();
|
snd.play(FModel.getPreferences().getPrefInt(FPref.UI_VOL_SOUNDS)/100f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -182,6 +194,12 @@ public class SoundSystem {
|
|||||||
changeBackgroundTrack();
|
changeBackgroundTrack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void adjustVolume(float value) {
|
||||||
|
if (currentTrack != null) {
|
||||||
|
currentTrack.setVolume(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void changeBackgroundTrack() {
|
public void changeBackgroundTrack() {
|
||||||
//ensure old track stopped and disposed of if needed
|
//ensure old track stopped and disposed of if needed
|
||||||
if (currentTrack != null) {
|
if (currentTrack != null) {
|
||||||
@@ -189,7 +207,9 @@ public class SoundSystem {
|
|||||||
currentTrack = null;
|
currentTrack = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPlaylist == null || !FModel.getPreferences().getPrefBoolean(FPref.UI_ENABLE_MUSIC)) {
|
if (currentPlaylist == null || GuiBase.getInterface().isLibgdxPort()
|
||||||
|
? FModel.getPreferences().getPrefInt(FPref.UI_VOL_MUSIC) < 1
|
||||||
|
: !FModel.getPreferences().getPrefBoolean(FPref.UI_ENABLE_MUSIC)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user