mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
Working audio rocker in settings menu.
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
package org.toop.app.menu;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.layout.StackPane;
|
||||
@@ -11,6 +10,8 @@ import javafx.scene.layout.VBox;
|
||||
import org.toop.app.App;
|
||||
import org.toop.framework.asset.ResourceManager;
|
||||
import org.toop.framework.asset.resources.LocalizationAsset;
|
||||
import org.toop.framework.audio.events.AudioEvents;
|
||||
import org.toop.framework.eventbus.EventFlow;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -34,6 +35,7 @@ public final class OptionsMenu extends Menu {
|
||||
screenDeviceSelectorCreation(),
|
||||
displayModeSelectorCreation(),
|
||||
selectFullscreenCreation(),
|
||||
volumeSelectorCreation(),
|
||||
exitOptionsButton);
|
||||
|
||||
optionsBox.setAlignment(Pos.CENTER);
|
||||
@@ -113,4 +115,28 @@ public final class OptionsMenu extends Menu {
|
||||
return setFullscreen;
|
||||
}
|
||||
|
||||
private Slider volumeSelectorCreation() {
|
||||
Slider volumeSlider = new Slider(0, 100, 50);
|
||||
new EventFlow()
|
||||
.addPostEvent(AudioEvents.GetCurrentVolume.class)
|
||||
.onResponse(AudioEvents.GetCurrentVolumeReponse.class, event -> {
|
||||
volumeSlider.setValue(event.currentVolume() * 100);
|
||||
}).asyncPostEvent();
|
||||
volumeSlider.setShowTickLabels(true);
|
||||
volumeSlider.setShowTickMarks(true);
|
||||
volumeSlider.setMajorTickUnit(25);
|
||||
volumeSlider.setMinorTickCount(4);
|
||||
volumeSlider.setBlockIncrement(5);
|
||||
volumeSlider.setMaxWidth(225);
|
||||
|
||||
Label valueLabel = new Label(String.valueOf((int) volumeSlider.getValue()));
|
||||
|
||||
volumeSlider.valueProperty().addListener((obs, oldVal, newVal) -> {
|
||||
valueLabel.setText(String.valueOf(newVal.intValue()));
|
||||
new EventFlow().addPostEvent(new AudioEvents.ChangeVolume(newVal.doubleValue()/100.0))
|
||||
.asyncPostEvent();
|
||||
});
|
||||
return volumeSlider;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user