mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
add: some more languages
This commit is contained in:
@@ -41,7 +41,7 @@ public class SoundManager {
|
||||
.listen(this::handleMusicStart)
|
||||
.listen(this::handleVolumeChange)
|
||||
.listen(this::handleGetCurrentVolume)
|
||||
.listen(AudioEvents.clickButton.class, _ -> {
|
||||
.listen(AudioEvents.ClickButton.class, _ -> {
|
||||
try {
|
||||
playSound("medium-button-click.wav", false);
|
||||
} catch (UnsupportedAudioFileException | LineUnavailableException | IOException e) {
|
||||
@@ -69,15 +69,16 @@ public class SoundManager {
|
||||
}
|
||||
|
||||
private void handleVolumeChange(AudioEvents.ChangeVolume event) {
|
||||
if (event.newVolume() > 1.0) this.volume = 1.0;
|
||||
else this.volume = Math.max(event.newVolume(), 0.0);
|
||||
double newVolume = event.newVolume() / 100.0;
|
||||
if (newVolume > 1.0) this.volume = 1.0;
|
||||
else this.volume = Math.max(newVolume, 0.0);
|
||||
for (MediaPlayer mediaPlayer : this.activeMusic) {
|
||||
mediaPlayer.setVolume(this.volume);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleGetCurrentVolume(AudioEvents.GetCurrentVolume event) {
|
||||
new EventFlow().addPostEvent(new AudioEvents.GetCurrentVolumeReponse(volume, event.snowflakeId()))
|
||||
new EventFlow().addPostEvent(new AudioEvents.GetCurrentVolumeReponse(volume * 100.0, event.snowflakeId()))
|
||||
.asyncPostEvent();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,5 +37,5 @@ public class AudioEvents extends EventsBase {
|
||||
return snowflakeId;
|
||||
}
|
||||
}
|
||||
public record clickButton() implements EventWithoutSnowflake {}
|
||||
public record ClickButton() implements EventWithoutSnowflake {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user