mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-25 03:29:44 +01:00
accidentally deleted volumeSlider
This commit is contained in:
parent
4820b8cf46
commit
3e487c00d5
@ -21,7 +21,7 @@ import pp.battleship.client.gui.GameMusic;
|
||||
import pp.dialog.Dialog;
|
||||
import pp.dialog.StateCheckboxModel;
|
||||
import pp.dialog.TextInputDialog;
|
||||
import pp.monopoly.client.gui.VolumeSlider;
|
||||
import pp.battleship.client.gui.VolumeSlider;
|
||||
|
||||
import static pp.util.PreferencesUtils.getPreferences;
|
||||
|
||||
|
@ -0,0 +1,36 @@
|
||||
package pp.battleship.client.gui;
|
||||
|
||||
import com.simsilica.lemur.Slider;
|
||||
|
||||
/**
|
||||
* The VolumeSlider class represents the Volume Slider in the Menu.
|
||||
* It extends the Slider class and provides functionalities for setting the music volume,
|
||||
* with the help of the Slider in the GUI
|
||||
*/
|
||||
public class VolumeSlider extends Slider {
|
||||
|
||||
private final GameMusic music;
|
||||
private double vol;
|
||||
|
||||
/**
|
||||
* Constructs the Volume Slider for the Menu dialog
|
||||
* @param music the music instance
|
||||
*/
|
||||
public VolumeSlider(GameMusic music) {
|
||||
super();
|
||||
this.music = music;
|
||||
vol = GameMusic.volumeInPreferences();
|
||||
getModel().setPercent(vol);
|
||||
}
|
||||
|
||||
/**
|
||||
* when triggered it updates the volume to the value set with the slider
|
||||
*/
|
||||
public void update() {
|
||||
if (vol != getModel().getPercent()) {
|
||||
vol = getModel().getPercent();
|
||||
music.setVolume( (float) vol);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user