added missing comments to public void setVolume and

public void update. Also removed unused import statements.
This commit is contained in:
Yvonne Schmidt 2024-10-08 22:45:28 +02:00
parent f541f3edc0
commit 3bdc9c20dc
2 changed files with 12 additions and 2 deletions

View File

@ -8,8 +8,7 @@ import com.jme3.asset.AssetLoadException;
import com.jme3.asset.AssetNotFoundException; import com.jme3.asset.AssetNotFoundException;
import com.jme3.audio.AudioData; import com.jme3.audio.AudioData;
import com.jme3.audio.AudioNode; import com.jme3.audio.AudioNode;
import pp.battleship.notification.GameEventListener;
import pp.battleship.notification.SoundEvent;
import java.lang.System.Logger; import java.lang.System.Logger;
import java.lang.System.Logger.Level; import java.lang.System.Logger.Level;
@ -116,6 +115,12 @@ public class GameMusic extends AbstractAppState {
return null; return null;
} }
/**
* Sets the vol param to the level set in PREFERENCES
*
* @param vol Volume level of the music as indicated by the Volume control Slider
*
*/
public void setVolume(float vol){ public void setVolume(float vol){
menuMusicModern.setVolume(vol); menuMusicModern.setVolume(vol);
PREFERENCES.putFloat(VOLUME_PREF, vol); PREFERENCES.putFloat(VOLUME_PREF, vol);

View File

@ -3,6 +3,7 @@ package pp.battleship.client.gui;
import com.simsilica.lemur.Slider; import com.simsilica.lemur.Slider;
import pp.battleship.client.GameMusic; import pp.battleship.client.GameMusic;
public class VolumeControl extends Slider { public class VolumeControl extends Slider {
private final GameMusic menuMusicModern; private final GameMusic menuMusicModern;
@ -16,6 +17,10 @@ public class VolumeControl extends Slider {
getModel().setPercent(vol); getModel().setPercent(vol);
} }
/**
* Updates the volume of the music to the appropriate level set by the User through the Volume control Slider
*
*/
public void update() { public void update() {
if (vol != getModel().getPercent()) { if (vol != getModel().getPercent()) {
vol = getModel().getPercent(); vol = getModel().getPercent();