v2.0.0: added a desktop setting for playing music when focus is lost
This commit is contained in:
@@ -273,6 +273,7 @@ windows.wndsettings$audiotab.music_mute=Mute Music
|
||||
windows.wndsettings$audiotab.sfx_vol=SFX Volume
|
||||
windows.wndsettings$audiotab.sfx_mute=Mute SFX
|
||||
windows.wndsettings$audiotab.ignore_silent=Ignore Silent Mode
|
||||
windows.wndsettings$audiotab.music_bg=Play Music in Background
|
||||
windows.wndsettings$langstab.title=Language Settings
|
||||
windows.wndsettings$langstab.completed=This language has been fully translated and reviewed.
|
||||
windows.wndsettings$langstab.unreviewed=_This language has not yet been reviewed._ It may contain errors, but all text has been translated.
|
||||
|
||||
@@ -281,6 +281,7 @@ public class SPDSettings extends GameSettings {
|
||||
public static final String KEY_SOUND_FX = "soundfx";
|
||||
public static final String KEY_SFX_VOL = "sfx_vol";
|
||||
public static final String KEY_IGNORE_SILENT= "ignore_silent";
|
||||
public static final String KEY_MUSIC_BG = "music_bg";
|
||||
|
||||
public static void music( boolean value ) {
|
||||
Music.INSTANCE.enable( value );
|
||||
@@ -326,6 +327,14 @@ public class SPDSettings extends GameSettings {
|
||||
public static boolean ignoreSilentMode(){
|
||||
return getBoolean( KEY_IGNORE_SILENT, false);
|
||||
}
|
||||
|
||||
public static void playMusicInBackground( boolean value ){
|
||||
put( KEY_MUSIC_BG, value);
|
||||
}
|
||||
|
||||
public static boolean playMusicInBackground(){
|
||||
return getBoolean( KEY_MUSIC_BG, true);
|
||||
}
|
||||
|
||||
//Languages and Font
|
||||
|
||||
|
||||
@@ -894,6 +894,7 @@ public class WndSettings extends WndTabbed {
|
||||
CheckBox chkMuteSFX;
|
||||
ColorBlock sep3;
|
||||
CheckBox chkIgnoreSilent;
|
||||
CheckBox chkMusicBG;
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
@@ -956,7 +957,7 @@ public class WndSettings extends WndTabbed {
|
||||
chkMuteSFX.checked(!SPDSettings.soundFx());
|
||||
add( chkMuteSFX );
|
||||
|
||||
if (DeviceCompat.isiOS() && Messages.lang() == Languages.ENGLISH){
|
||||
if (DeviceCompat.isiOS()){
|
||||
|
||||
sep3 = new ColorBlock(1, 1, 0xFF000000);
|
||||
add(sep3);
|
||||
@@ -970,6 +971,21 @@ public class WndSettings extends WndTabbed {
|
||||
};
|
||||
chkIgnoreSilent.checked(SPDSettings.ignoreSilentMode());
|
||||
add(chkIgnoreSilent);
|
||||
|
||||
} else if (DeviceCompat.isDesktop()){
|
||||
|
||||
sep3 = new ColorBlock(1, 1, 0xFF000000);
|
||||
add(sep3);
|
||||
|
||||
chkMusicBG = new CheckBox( Messages.get(this, "music_bg") ){
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
SPDSettings.playMusicInBackground(checked());
|
||||
}
|
||||
};
|
||||
chkMusicBG.checked(SPDSettings.playMusicInBackground());
|
||||
add(chkMusicBG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1008,6 +1024,12 @@ public class WndSettings extends WndTabbed {
|
||||
|
||||
chkIgnoreSilent.setRect(0, sep3.y + 1 + GAP, width, BTN_HEIGHT);
|
||||
height = chkIgnoreSilent.bottom();
|
||||
} else if (chkMusicBG != null){
|
||||
sep3.size(width, 1);
|
||||
sep3.y = chkMuteSFX.bottom() + GAP;
|
||||
|
||||
chkMusicBG.setRect(0, sep3.y + 1 + GAP, width, BTN_HEIGHT);
|
||||
height = chkMusicBG.bottom();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3WindowListener;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.watabou.noosa.audio.Music;
|
||||
|
||||
public class DesktopWindowListener implements Lwjgl3WindowListener {
|
||||
|
||||
@@ -41,8 +42,16 @@ public class DesktopWindowListener implements Lwjgl3WindowListener {
|
||||
|
||||
@Override
|
||||
public void iconified ( boolean b ) { }
|
||||
public void focusLost () { }
|
||||
public void focusGained () { }
|
||||
public void focusLost () {
|
||||
if (!SPDSettings.playMusicInBackground()) {
|
||||
Music.INSTANCE.pause();
|
||||
}
|
||||
}
|
||||
public void focusGained () {
|
||||
if (!SPDSettings.playMusicInBackground()){
|
||||
Music.INSTANCE.resume();
|
||||
}
|
||||
}
|
||||
public boolean closeRequested () { return true; }
|
||||
public void filesDropped ( String[] strings ) { }
|
||||
public void refreshRequested () { }
|
||||
|
||||
Reference in New Issue
Block a user