com.realtime.crossfire.jxclient.sound
Class SoundManager

java.lang.Object
  extended by com.realtime.crossfire.jxclient.sound.SoundManager

public class SoundManager
extends java.lang.Object

Manages all sounds. Each sound has a sound type (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.


Field Summary
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 Summary
SoundManager(GuiStateManager guiStateManager, DebugWriter debugSound)
          Creates a new instance.
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

clipManager

@NotNull
private final ClipManager clipManager
The clip manager for playing sound effects.


debugSound

@Nullable
private final DebugWriter debugSound
The writer for logging sound related information or null to not log.


enabled

private boolean enabled
Whether sound is enabled.


guiStateListener

@NotNull
private final GuiStateListener guiStateListener
The GuiStateListener for detecting established or dropped connections.


musicManager

@NotNull
private final MusicManager musicManager
The music manager for playing background music.


mutedSounds

@NotNull
private final java.util.Collection<Sounds> mutedSounds
The muted sounds.

Constructor Detail

SoundManager

public SoundManager(@NotNull
                    GuiStateManager guiStateManager,
                    @Nullable
                    DebugWriter debugSound)
Creates a new instance.

Parameters:
guiStateManager - the gui state manager to watch
debugSound - the writer for logging sound related information or null to not log
Method Detail

mute

private void mute(@NotNull
                  Sounds type,
                  boolean mute)
Mutes or unmutes sound effects.

Parameters:
type - the sound type to affect
mute - whether to mute (true) or unmute (false)

muteMusic

private void muteMusic(boolean muted)
Mutes or unmutes background music.

Parameters:
muted - whether to mute (true) or unmute (false)

playClip

public void playClip(@NotNull
                     Sounds type,
                     @Nullable
                     java.lang.String name,
                     @NotNull
                     java.lang.String action)
Plays a sound clip.

Parameters:
type - the sound type
name - an optional prefix for the action name
action - the sound action name

playMusic

public void playMusic(@Nullable
                      java.lang.String name)
Plays a background music. If the new music name is unchanged, continue playing.

Parameters:
name - the music name

setEnabled

public void setEnabled(boolean enabled)
Sets whether the sound system is enabled.

Parameters:
enabled - whether the sound system is enabled

shutdown

public void shutdown()
Terminates all sounds and free resources.