v0.8.1: adjusted volume sliders to use an exponential scale

This commit is contained in:
Evan Debenham 2020-05-19 19:55:08 -04:00
parent 806e829000
commit 5987a43150
3 changed files with 6 additions and 4 deletions

View File

@ -201,7 +201,7 @@ public class SPDSettings extends GameSettings {
} }
public static void musicVol( int value ){ public static void musicVol( int value ){
Music.INSTANCE.volume(value/10f); Music.INSTANCE.volume(value*value/100f);
put( KEY_MUSIC_VOL, value ); put( KEY_MUSIC_VOL, value );
} }
@ -219,7 +219,7 @@ public class SPDSettings extends GameSettings {
} }
public static void SFXVol( int value ) { public static void SFXVol( int value ) {
Sample.INSTANCE.volume(value/10f); Sample.INSTANCE.volume(value*value/100f);
put( KEY_SFX_VOL, value ); put( KEY_SFX_VOL, value );
} }

View File

@ -149,9 +149,9 @@ public class ShatteredPixelDungeon extends Game {
SPDAction.loadBindings(); SPDAction.loadBindings();
Music.INSTANCE.enable( SPDSettings.music() ); Music.INSTANCE.enable( SPDSettings.music() );
Music.INSTANCE.volume( SPDSettings.musicVol()/10f ); Music.INSTANCE.volume( SPDSettings.musicVol()*SPDSettings.musicVol()/100f );
Sample.INSTANCE.enable( SPDSettings.soundFx() ); Sample.INSTANCE.enable( SPDSettings.soundFx() );
Sample.INSTANCE.volume( SPDSettings.SFXVol()/10f ); Sample.INSTANCE.volume( SPDSettings.SFXVol()*SPDSettings.SFXVol()/100f );
Sample.INSTANCE.load( Assets.Sounds.all ); Sample.INSTANCE.load( Assets.Sounds.all );

View File

@ -36,6 +36,7 @@ import com.watabou.noosa.Game;
import com.watabou.noosa.Group; import com.watabou.noosa.Group;
import com.watabou.noosa.audio.Sample; import com.watabou.noosa.audio.Sample;
import com.watabou.utils.DeviceCompat; import com.watabou.utils.DeviceCompat;
import com.watabou.utils.Random;
//TODO seeing as a fair bit of this is platform-dependant, might be better to have a per-platform wndsettings //TODO seeing as a fair bit of this is platform-dependant, might be better to have a per-platform wndsettings
public class WndSettings extends WndTabbed { public class WndSettings extends WndTabbed {
@ -351,6 +352,7 @@ public class WndSettings extends WndTabbed {
@Override @Override
protected void onChange() { protected void onChange() {
SPDSettings.SFXVol(getSelectedValue()); SPDSettings.SFXVol(getSelectedValue());
Sample.INSTANCE.play(Random.element(Assets.Sounds.all));
} }
}; };
SFXVol.setSelectedValue(SPDSettings.SFXVol()); SFXVol.setSelectedValue(SPDSettings.SFXVol());