feat(io): MusicLevel enum (Off/Low/Med/High)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package thb.jeanluc.adventure.io;
|
||||
|
||||
/** Background-music volume level, cycled in the Settings menu. */
|
||||
public enum MusicLevel {
|
||||
OFF, LOW, MEDIUM, HIGH;
|
||||
|
||||
/** Target MASTER_GAIN in decibels. Irrelevant for {@link #OFF} (playback disabled). */
|
||||
public float gainDb() {
|
||||
return switch (this) {
|
||||
case OFF -> Float.NEGATIVE_INFINITY;
|
||||
case LOW -> -20f;
|
||||
case MEDIUM -> -10f;
|
||||
case HIGH -> 0f;
|
||||
};
|
||||
}
|
||||
|
||||
/** @return true when music should play. */
|
||||
public boolean isOn() {
|
||||
return this != OFF;
|
||||
}
|
||||
|
||||
/** Next level in the cycle (wraps HIGH → OFF). */
|
||||
public MusicLevel next() {
|
||||
return values()[(ordinal() + 1) % values().length];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user