mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- CheckStyle.
This commit is contained in:
@@ -80,10 +80,13 @@ public class ReadPriceList {
|
|||||||
|
|
||||||
List<String> lines = FileUtil.readFile(file);
|
List<String> lines = FileUtil.readFile(file);
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
if ( line.trim().length() == 0 ) break;
|
if (line.trim().length() == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (line.startsWith(ReadPriceList.COMMENT))
|
if (line.startsWith(ReadPriceList.COMMENT)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
final String[] s = line.split("=");
|
final String[] s = line.split("=");
|
||||||
final String name = s[0].trim();
|
final String name = s[0].trim();
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class AudioClip implements IAudioClip{
|
|||||||
private final Clip clip;
|
private final Clip clip;
|
||||||
private final int SOUND_SYSTEM_DELAY = 30;
|
private final int SOUND_SYSTEM_DELAY = 30;
|
||||||
|
|
||||||
private final static String PathToSound = "res/sound";
|
private static final String PathToSound = "res/sound";
|
||||||
|
|
||||||
public static boolean fileExists(String fileName) {
|
public static boolean fileExists(String fileName) {
|
||||||
File fSound = new File(PathToSound, fileName);
|
File fSound = new File(PathToSound, fileName);
|
||||||
@@ -52,8 +52,9 @@ public class AudioClip implements IAudioClip{
|
|||||||
|
|
||||||
public AudioClip(final String filename) {
|
public AudioClip(final String filename) {
|
||||||
File fSound = new File(PathToSound, filename);
|
File fSound = new File(PathToSound, filename);
|
||||||
if ( !fSound.exists() )
|
if (!fSound.exists()) {
|
||||||
throw new IllegalArgumentException("Sound file " + fSound.toString() + " does not exist, cannot make a clip of it");
|
throw new IllegalArgumentException("Sound file " + fSound.toString() + " does not exist, cannot make a clip of it");
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
AudioInputStream stream = AudioSystem.getAudioInputStream(fSound);
|
AudioInputStream stream = AudioSystem.getAudioInputStream(fSound);
|
||||||
@@ -74,8 +75,9 @@ public class AudioClip implements IAudioClip{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void play() {
|
public final void play() {
|
||||||
if (null == clip)
|
if (null == clip) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
clip.setMicrosecondPosition(0);
|
clip.setMicrosecondPosition(0);
|
||||||
try {
|
try {
|
||||||
Thread.sleep(SOUND_SYSTEM_DELAY);
|
Thread.sleep(SOUND_SYSTEM_DELAY);
|
||||||
@@ -86,8 +88,9 @@ public class AudioClip implements IAudioClip{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void loop() {
|
public final void loop() {
|
||||||
if (null == clip)
|
if (null == clip) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
clip.setMicrosecondPosition(0);
|
clip.setMicrosecondPosition(0);
|
||||||
try {
|
try {
|
||||||
Thread.sleep(SOUND_SYSTEM_DELAY);
|
Thread.sleep(SOUND_SYSTEM_DELAY);
|
||||||
@@ -98,14 +101,16 @@ public class AudioClip implements IAudioClip{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void stop() {
|
public final void stop() {
|
||||||
if (null == clip)
|
if (null == clip) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
clip.stop();
|
clip.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isDone() {
|
public final boolean isDone() {
|
||||||
if (null == clip)
|
if (null == clip) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return !clip.isRunning();
|
return !clip.isRunning();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ import forge.game.event.SpellResolvedEvent;
|
|||||||
import forge.game.event.TokenCreatedEvent;
|
import forge.game.event.TokenCreatedEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is in charge of converting any forge.game.event.Event to a SoundEffectType
|
* This class is in charge of converting any forge.game.event.Event to a SoundEffectType.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class EventVisualizer {
|
public class EventVisualizer {
|
||||||
|
|
||||||
final static Map<Class<?>, SoundEffectType> matchTable = new HashMap<Class<?>, SoundEffectType>();
|
static final Map<Class<?>, SoundEffectType> matchTable = new HashMap<Class<?>, SoundEffectType>();
|
||||||
|
|
||||||
public EventVisualizer() {
|
public EventVisualizer() {
|
||||||
matchTable.put(CounterAddedEvent.class, SoundEffectType.AddCounter);
|
matchTable.put(CounterAddedEvent.class, SoundEffectType.AddCounter);
|
||||||
@@ -113,7 +113,9 @@ public class EventVisualizer {
|
|||||||
// if there's a specific effect for this particular card, play it and
|
// if there's a specific effect for this particular card, play it and
|
||||||
// we're done.
|
// we're done.
|
||||||
SoundEffectType specialEffect = getSpecificCardEffect(source);
|
SoundEffectType specialEffect = getSpecificCardEffect(source);
|
||||||
if( specialEffect != null ) return specialEffect;
|
if (specialEffect != null) {
|
||||||
|
return specialEffect;
|
||||||
|
}
|
||||||
|
|
||||||
if (source.isCreature() && source.isArtifact()) {
|
if (source.isCreature() && source.isArtifact()) {
|
||||||
return SoundEffectType.ArtifactCreature;
|
return SoundEffectType.ArtifactCreature;
|
||||||
@@ -160,7 +162,9 @@ public class EventVisualizer {
|
|||||||
// if there's a specific effect for this particular card, play it and
|
// if there's a specific effect for this particular card, play it and
|
||||||
// we're done.
|
// we're done.
|
||||||
SoundEffectType specialEffect = getSpecificCardEffect(land);
|
SoundEffectType specialEffect = getSpecificCardEffect(land);
|
||||||
if( specialEffect != null ) return specialEffect;
|
if (specialEffect != null) {
|
||||||
|
return specialEffect;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
final List<SpellAbility> manaProduced = land.getManaAbility();
|
final List<SpellAbility> manaProduced = land.getManaAbility();
|
||||||
|
|||||||
@@ -15,15 +15,16 @@ import forge.properties.ForgePreferences.FPref;
|
|||||||
*/
|
*/
|
||||||
public class SoundSystem {
|
public class SoundSystem {
|
||||||
|
|
||||||
private final static IAudioClip emptySound = new NoSoundClip();
|
private static final IAudioClip emptySound = new NoSoundClip();
|
||||||
private final static Map<SoundEffectType, IAudioClip> loadedClips = new EnumMap<SoundEffectType, IAudioClip>(SoundEffectType.class);
|
private static final Map<SoundEffectType, IAudioClip> loadedClips = new EnumMap<SoundEffectType, IAudioClip>(SoundEffectType.class);
|
||||||
|
|
||||||
private final EventVisualizer visualizer = new EventVisualizer();
|
private final EventVisualizer visualizer = new EventVisualizer();
|
||||||
|
|
||||||
protected IAudioClip fetchResource(SoundEffectType type) {
|
protected IAudioClip fetchResource(SoundEffectType type) {
|
||||||
|
|
||||||
if (!Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ENABLE_SOUNDS))
|
if (!Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ENABLE_SOUNDS)) {
|
||||||
return emptySound;
|
return emptySound;
|
||||||
|
}
|
||||||
|
|
||||||
IAudioClip clip = loadedClips.get(type);
|
IAudioClip clip = loadedClips.get(type);
|
||||||
if (null == clip) { // cache miss
|
if (null == clip) { // cache miss
|
||||||
@@ -71,12 +72,15 @@ public class SoundSystem {
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void receiveEvent(Event evt) {
|
public void receiveEvent(Event evt) {
|
||||||
SoundEffectType effect = visualizer.getSoundForEvent(evt);
|
SoundEffectType effect = visualizer.getSoundForEvent(evt);
|
||||||
if ( null == effect ) return;
|
if (null == effect) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
boolean isSync = visualizer.isSyncSound(effect);
|
boolean isSync = visualizer.isSyncSound(effect);
|
||||||
if ( isSync )
|
if (isSync) {
|
||||||
playSync(effect);
|
playSync(effect);
|
||||||
else
|
} else {
|
||||||
play(effect);
|
play(effect);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user