mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
[Mobile] set volume when track changes
This commit is contained in:
@@ -27,7 +27,6 @@ import forge.properties.ForgeConstants;
|
|||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
|
|||||||
@@ -78,8 +78,6 @@ 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) {
|
||||||
@@ -120,9 +118,6 @@ 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,8 +1,9 @@
|
|||||||
package forge.animation;
|
package forge.animation;
|
||||||
|
|
||||||
import forge.Forge;
|
|
||||||
import forge.Graphics;
|
import forge.Graphics;
|
||||||
|
import forge.model.FModel;
|
||||||
import forge.properties.ForgeConstants;
|
import forge.properties.ForgeConstants;
|
||||||
|
import forge.properties.ForgePreferences;
|
||||||
import forge.sound.AudioClip;
|
import forge.sound.AudioClip;
|
||||||
|
|
||||||
public enum AbilityEffect {
|
public enum AbilityEffect {
|
||||||
@@ -24,7 +25,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(Forge.clipVol);
|
soundClip.play(FModel.getPreferences().getPrefInt(ForgePreferences.FPref.UI_VOL_SOUNDS)/100f);
|
||||||
animation.start();
|
animation.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -442,19 +442,8 @@ public class SettingsPage extends TabPage<SettingsScreen> {
|
|||||||
lstSettings.addItem(new CustomSelectSetting(FPref.UI_VOL_SOUNDS,
|
lstSettings.addItem(new CustomSelectSetting(FPref.UI_VOL_SOUNDS,
|
||||||
localizer.getMessage("cbAdjustSoundsVolume"),
|
localizer.getMessage("cbAdjustSoundsVolume"),
|
||||||
localizer.getMessage("nlAdjustSoundsVolume"),
|
localizer.getMessage("nlAdjustSoundsVolume"),
|
||||||
new String[]{"0", "25", "50", "75", "100"}) {
|
new String[]{"0", "25", "50", "75", "100"}),
|
||||||
@Override
|
7);
|
||||||
public void valueChanged(String newValue) {
|
|
||||||
super.valueChanged(newValue);
|
|
||||||
try {
|
|
||||||
int val = Integer.parseInt(newValue);
|
|
||||||
Forge.clipVol = val/100f;
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
Forge.clipVol = 1f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 7);
|
|
||||||
lstSettings.addItem(new CustomSelectSetting(FPref.UI_VOL_MUSIC,
|
lstSettings.addItem(new CustomSelectSetting(FPref.UI_VOL_MUSIC,
|
||||||
localizer.getMessage("cbAdjustMusicVolume"),
|
localizer.getMessage("cbAdjustMusicVolume"),
|
||||||
localizer.getMessage("nlAdjustMusicVolume"),
|
localizer.getMessage("nlAdjustMusicVolume"),
|
||||||
@@ -462,16 +451,8 @@ public class SettingsPage extends TabPage<SettingsScreen> {
|
|||||||
@Override
|
@Override
|
||||||
public void valueChanged(String newValue) {
|
public void valueChanged(String newValue) {
|
||||||
super.valueChanged(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
|
//update background music when this setting changes
|
||||||
SoundSystem.instance.changeBackgroundTrack();
|
SoundSystem.instance.changeBackgroundTrack();
|
||||||
SoundSystem.instance.adjustVolume(Forge.musicVol);
|
|
||||||
}
|
}
|
||||||
}, 7);
|
}, 7);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -194,12 +194,6 @@ 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) {
|
||||||
@@ -228,6 +222,7 @@ public class SoundSystem {
|
|||||||
changeBackgroundTrack(); //change track when music completes on its own
|
changeBackgroundTrack(); //change track when music completes on its own
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
currentTrack.setVolume(FModel.getPreferences().getPrefInt(FPref.UI_VOL_MUSIC)/100f);
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
System.err.println("Unable to load music file: " + filename);
|
System.err.println("Unable to load music file: " + filename);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user