mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- Sound system: made the Sounds methods obey the "enable sounds" setting in preferences.
This commit is contained in:
@@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
package forge.sound;
|
package forge.sound;
|
||||||
|
|
||||||
|
import forge.Singletons;
|
||||||
|
import forge.properties.ForgePreferences.FPref;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sounds (enumeration) - all sounds in the game must be declared here.
|
* Sounds (enumeration) - all sounds in the game must be declared here.
|
||||||
* Once declared, the sound can be played from anywhere in the code
|
* Once declared, the sound can be played from anywhere in the code
|
||||||
@@ -31,12 +34,18 @@ package forge.sound;
|
|||||||
* @author Agetian
|
* @author Agetian
|
||||||
*/
|
*/
|
||||||
public enum Sounds {
|
public enum Sounds {
|
||||||
|
// Sounds must be listed in alphabetic order.
|
||||||
LoseDuel("res/sound/lose_duel.wav"),
|
LoseDuel("res/sound/lose_duel.wav"),
|
||||||
|
Shuffle("res/sound/shuffle.wav"),
|
||||||
Tap("res/sound/tap.wav"),
|
Tap("res/sound/tap.wav"),
|
||||||
WinDuel("res/sound/win_duel.wav");
|
WinDuel("res/sound/win_duel.wav");
|
||||||
|
|
||||||
SoundSystem snd = null;
|
SoundSystem snd = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param filename
|
||||||
|
* name of the sound file associated with the entry.
|
||||||
|
*/
|
||||||
Sounds(String filename) {
|
Sounds(String filename) {
|
||||||
snd = new SoundSystem(filename);
|
snd = new SoundSystem(filename);
|
||||||
}
|
}
|
||||||
@@ -45,20 +54,26 @@ public enum Sounds {
|
|||||||
* Play the sound associated with the Sounds enumeration element.
|
* Play the sound associated with the Sounds enumeration element.
|
||||||
*/
|
*/
|
||||||
public void play() {
|
public void play() {
|
||||||
|
if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ENABLE_SOUNDS)) {
|
||||||
snd.play();
|
snd.play();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Play the sound in a looping manner until 'stop' is called.
|
* Play the sound in a looping manner until 'stop' is called.
|
||||||
*/
|
*/
|
||||||
public void loop() {
|
public void loop() {
|
||||||
|
if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ENABLE_SOUNDS)) {
|
||||||
snd.loop();
|
snd.loop();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop the sound associated with the Sounds enumeration element.
|
* Stop the sound associated with the Sounds enumeration element.
|
||||||
*/
|
*/
|
||||||
public void stop() {
|
public void stop() {
|
||||||
|
if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ENABLE_SOUNDS)) {
|
||||||
snd.stop();
|
snd.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user