v0.3.1: added a new menu for audio settings which allows finer audio control
This commit is contained in:
parent
12f1302e0f
commit
d1d918290a
|
@ -32,7 +32,9 @@ enum Preferences {
|
|||
public static final String KEY_IMMERSIVE = "immersive";
|
||||
public static final String KEY_SCALE = "scale";
|
||||
public static final String KEY_MUSIC = "music";
|
||||
public static final String KEY_MUSIC_VOL = "music_vol";
|
||||
public static final String KEY_SOUND_FX = "soundfx";
|
||||
public static final String KEY_SFX_VOL = "sfx_vol";
|
||||
public static final String KEY_ZOOM = "zoom";
|
||||
public static final String KEY_LAST_CLASS = "last_class";
|
||||
public static final String KEY_CHALLENGES = "challenges";
|
||||
|
|
|
@ -279,6 +279,14 @@ public class ShatteredPixelDungeon extends Game {
|
|||
public static boolean music() {
|
||||
return Preferences.INSTANCE.getBoolean( Preferences.KEY_MUSIC, true );
|
||||
}
|
||||
|
||||
public static void musicVol( int value ){
|
||||
Preferences.INSTANCE.put( Preferences.KEY_MUSIC_VOL, value );
|
||||
}
|
||||
|
||||
public static int musicVol(){
|
||||
return Preferences.INSTANCE.getInt( Preferences.KEY_MUSIC_VOL, 10 );
|
||||
}
|
||||
|
||||
public static void soundFx( boolean value ) {
|
||||
Sample.INSTANCE.enable( value );
|
||||
|
@ -288,6 +296,14 @@ public class ShatteredPixelDungeon extends Game {
|
|||
public static boolean soundFx() {
|
||||
return Preferences.INSTANCE.getBoolean( Preferences.KEY_SOUND_FX, true );
|
||||
}
|
||||
|
||||
public static void SFXVol( int value ) {
|
||||
Preferences.INSTANCE.put( Preferences.KEY_SFX_VOL, value );
|
||||
}
|
||||
|
||||
public static int SFXVol() {
|
||||
return Preferences.INSTANCE.getInt( Preferences.KEY_SFX_VOL, 10 );
|
||||
}
|
||||
|
||||
public static void brightness( int value ) {
|
||||
Preferences.INSTANCE.put( Preferences.KEY_BRIGHTNESS, value );
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2015 Evan Debenham
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.CheckBox;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.OptionSlider;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.audio.Music;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
|
||||
public class WndAudio extends Window {
|
||||
|
||||
private static final int WIDTH = 112;
|
||||
private static final int SLIDER_HEIGHT = 25;
|
||||
private static final int BTN_HEIGHT = 20;
|
||||
private static final int GAP_SML = 2;
|
||||
private static final int GAP_LRG = 6;
|
||||
|
||||
public WndAudio(){
|
||||
|
||||
OptionSlider musicVol = new OptionSlider("Music Volume", "0", "10", 0, 10) {
|
||||
@Override
|
||||
protected void onChange() {
|
||||
Music.INSTANCE.volume(getSelectedValue()/10f);
|
||||
ShatteredPixelDungeon.musicVol(getSelectedValue());
|
||||
}
|
||||
};
|
||||
musicVol.setSelectedValue(ShatteredPixelDungeon.musicVol());
|
||||
musicVol.setRect(0, 0, WIDTH, SLIDER_HEIGHT);
|
||||
add(musicVol);
|
||||
|
||||
CheckBox musicMute = new CheckBox("Mute Music"){
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
ShatteredPixelDungeon.music(!checked());
|
||||
}
|
||||
};
|
||||
musicMute.setRect(0, musicVol.bottom() + GAP_SML, WIDTH, BTN_HEIGHT);
|
||||
musicMute.checked(!ShatteredPixelDungeon.music());
|
||||
add(musicMute);
|
||||
|
||||
|
||||
OptionSlider SFXVol = new OptionSlider("SFX Volume", "0", "10", 0, 10) {
|
||||
@Override
|
||||
protected void onChange() {
|
||||
Sample.INSTANCE.volume(getSelectedValue()/10f);
|
||||
ShatteredPixelDungeon.SFXVol(getSelectedValue());
|
||||
}
|
||||
};
|
||||
SFXVol.setSelectedValue(ShatteredPixelDungeon.SFXVol());
|
||||
SFXVol.setRect(0, musicMute.bottom() + GAP_LRG, WIDTH, SLIDER_HEIGHT);
|
||||
add(SFXVol);
|
||||
|
||||
CheckBox btnSound = new CheckBox( "Mute SFX" ) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
ShatteredPixelDungeon.soundFx(!checked());
|
||||
Sample.INSTANCE.play( Assets.SND_CLICK );
|
||||
}
|
||||
};
|
||||
btnSound.setRect(0, SFXVol.bottom() + GAP_SML, WIDTH, BTN_HEIGHT);
|
||||
btnSound.checked(!ShatteredPixelDungeon.soundFx());
|
||||
add( btnSound );
|
||||
|
||||
resize( WIDTH, (int)btnSound.bottom());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -59,6 +59,14 @@ public class WndGame extends Window {
|
|||
hide();
|
||||
GameScene.show( new WndSettings( true ) );
|
||||
}
|
||||
});
|
||||
|
||||
addButton( new RedButton( "Audio Settings" ) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
hide();
|
||||
GameScene.show( new WndAudio( ) );
|
||||
}
|
||||
} );
|
||||
|
||||
// Challenges window
|
||||
|
|
|
@ -26,8 +26,6 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.Toolbar;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.CheckBox;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
|
||||
|
@ -41,11 +39,7 @@ public class WndSettings extends Window {
|
|||
|
||||
private static final String TXT_SCALE = "UI Scale: %dX";
|
||||
private static final String TXT_IMMERSIVE = "Immersive mode";
|
||||
|
||||
private static final String TXT_MUSIC = "Music";
|
||||
|
||||
private static final String TXT_SOUND = "Sound FX";
|
||||
|
||||
|
||||
private static final String TXT_BRIGHTNESS = "Brightness: %s";
|
||||
|
||||
private static final String TXT_QUICKSLOT = "QuickSlots: %s";
|
||||
|
@ -125,30 +119,17 @@ public class WndSettings extends Window {
|
|||
|
||||
}
|
||||
|
||||
CheckBox btnMusic = new CheckBox( TXT_MUSIC ) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
ShatteredPixelDungeon.music(checked());
|
||||
}
|
||||
};
|
||||
btnMusic.setRect( 0, (btnImmersive != null ? btnImmersive.bottom() : BTN_HEIGHT) + GAP, WIDTH, BTN_HEIGHT );
|
||||
btnMusic.checked( ShatteredPixelDungeon.music() );
|
||||
add( btnMusic );
|
||||
|
||||
CheckBox btnSound = new CheckBox( TXT_SOUND ) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
ShatteredPixelDungeon.soundFx(checked());
|
||||
Sample.INSTANCE.play( Assets.SND_CLICK );
|
||||
}
|
||||
};
|
||||
btnSound.setRect( 0, btnMusic.bottom() + GAP, WIDTH, BTN_HEIGHT );
|
||||
btnSound.checked( ShatteredPixelDungeon.soundFx() );
|
||||
add( btnSound );
|
||||
|
||||
if (!inGame) {
|
||||
|
||||
RedButton btnAudio = new RedButton("Audio Settings") {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
hide();
|
||||
Game.scene().add(new WndAudio());
|
||||
}
|
||||
};
|
||||
btnAudio.setRect( 0, btnImmersive.bottom() + GAP, WIDTH, BTN_HEIGHT );
|
||||
add( btnAudio );
|
||||
|
||||
RedButton btnOrientation = new RedButton( orientationText() ) {
|
||||
@Override
|
||||
|
@ -156,7 +137,7 @@ public class WndSettings extends Window {
|
|||
ShatteredPixelDungeon.landscape(!ShatteredPixelDungeon.landscape());
|
||||
}
|
||||
};
|
||||
btnOrientation.setRect( 0, btnSound.bottom() + GAP, WIDTH, BTN_HEIGHT );
|
||||
btnOrientation.setRect( 0, btnAudio.bottom() + GAP, WIDTH, BTN_HEIGHT );
|
||||
add( btnOrientation );
|
||||
|
||||
resize( WIDTH, (int)btnOrientation.bottom() );
|
||||
|
@ -173,7 +154,7 @@ public class WndSettings extends Window {
|
|||
this.text(Utils.format(TXT_BRIGHTNESS, brightness));
|
||||
}
|
||||
};
|
||||
btnBrightness.setRect(0, btnSound.bottom() + GAP, WIDTH, BTN_HEIGHT);
|
||||
btnBrightness.setRect(0, btnZoomIn.bottom() + GAP, WIDTH, BTN_HEIGHT);
|
||||
add(btnBrightness);
|
||||
|
||||
RedButton btnQuickSlot = new RedButton( Utils.format(TXT_QUICKSLOT, ShatteredPixelDungeon.quickSlots()) ) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user