public class SoundManager
extends java.lang.Object
Sounds
) attached.
Sound types can be disabled (by the user) or muted (by the application). A
sound is played only if it is neither disabled nor muted.Modifier and Type | Field and Description |
---|---|
private ClipManager |
clipManager
The clip manager for playing sound effects.
|
private DebugWriter |
debugSound
The writer for logging sound related information or
null to not
log. |
private boolean |
enabled
Whether sound is enabled.
|
private GuiStateListener |
guiStateListener
The
GuiStateListener for detecting established or dropped
connections. |
private MusicManager |
musicManager
The music manager for playing background music.
|
private java.util.Collection<Sounds> |
mutedSounds
The muted sounds.
|
Constructor and Description |
---|
SoundManager(GuiStateManager guiStateManager,
DebugWriter debugSound)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
private void |
mute(Sounds type,
boolean mute)
Mutes or unmutes sound effects.
|
private void |
muteMusic(boolean muted)
Mutes or unmutes background music.
|
void |
playClip(Sounds type,
java.lang.String name,
java.lang.String action)
Plays a sound clip.
|
void |
playMusic(java.lang.String name)
Plays a background music.
|
void |
setEnabled(boolean enabled)
Sets whether the sound system is enabled.
|
void |
shutdown()
Terminates all sounds and free resources.
|
@NotNull private final ClipManager clipManager
@Nullable private final DebugWriter debugSound
null
to not
log.private boolean enabled
@NotNull private final GuiStateListener guiStateListener
GuiStateListener
for detecting established or dropped
connections.@NotNull private final MusicManager musicManager
@NotNull private final java.util.Collection<Sounds> mutedSounds
public SoundManager(@NotNull GuiStateManager guiStateManager, @Nullable DebugWriter debugSound)
guiStateManager
- the gui state manager to watchdebugSound
- the writer for logging sound related information or
null
to not logprivate void mute(@NotNull Sounds type, boolean mute)
type
- the sound type to affectmute
- whether to mute (true
) or unmute (false
)private void muteMusic(boolean muted)
muted
- whether to mute (true
) or unmute (false
)public void playClip(@NotNull Sounds type, @Nullable java.lang.String name, @NotNull java.lang.String action)
type
- the sound typename
- an optional prefix for the action nameaction
- the sound action namepublic void playMusic(@Nullable java.lang.String name)
name
- the music namepublic void setEnabled(boolean enabled)
enabled
- whether the sound system is enabledpublic void shutdown()