mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 02:44:50 +00:00
Working audio rocker in settings menu.
This commit is contained in:
@@ -37,6 +37,7 @@ public class SoundManager {
|
||||
.listen(this::handleStopSound)
|
||||
.listen(this::handleMusicStart)
|
||||
.listen(this::handleVolumeChange)
|
||||
.listen(this::handleGetCurrentVolume)
|
||||
.listen(AudioEvents.playOnClickButton.class, _ -> {
|
||||
try {
|
||||
playSound("hitsound0.wav", false);
|
||||
@@ -70,6 +71,12 @@ public class SoundManager {
|
||||
for (MediaPlayer mediaPlayer : this.activeMusic) {
|
||||
mediaPlayer.setVolume(this.volume);
|
||||
}
|
||||
IO.println("Volume: " + this.volume);
|
||||
}
|
||||
|
||||
private void handleGetCurrentVolume(AudioEvents.GetCurrentVolume event) {
|
||||
new EventFlow().addPostEvent(new AudioEvents.GetCurrentVolumeReponse(volume, event.snowflakeId()))
|
||||
.asyncPostEvent();
|
||||
}
|
||||
|
||||
private void handleMusicStart(AudioEvents.StartBackgroundMusic e) {
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package org.toop.framework.audio.events;
|
||||
|
||||
import org.toop.framework.asset.resources.MusicAsset;
|
||||
import org.toop.framework.eventbus.events.EventWithSnowflake;
|
||||
import org.toop.framework.eventbus.events.EventWithoutSnowflake;
|
||||
import org.toop.framework.eventbus.events.EventsBase;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class AudioEvents extends EventsBase {
|
||||
/** Starts playing a sound. */
|
||||
public record PlayAudio(String fileName, boolean loop)
|
||||
@@ -13,5 +16,27 @@ public class AudioEvents extends EventsBase {
|
||||
|
||||
public record StartBackgroundMusic() implements EventWithoutSnowflake {}
|
||||
public record ChangeVolume(double newVolume) implements EventWithoutSnowflake {}
|
||||
public record GetCurrentVolume(long snowflakeId) implements EventWithSnowflake {
|
||||
@Override
|
||||
public Map<String, Object> result() {
|
||||
return Map.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long eventSnowflake() {
|
||||
return snowflakeId;
|
||||
}
|
||||
}
|
||||
public record GetCurrentVolumeReponse(double currentVolume, long snowflakeId) implements EventWithSnowflake {
|
||||
@Override
|
||||
public Map<String, Object> result() {
|
||||
return Map.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long eventSnowflake() {
|
||||
return snowflakeId;
|
||||
}
|
||||
}
|
||||
public record playOnClickButton() implements EventWithoutSnowflake {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user