v1.1.2: added an option to override silent mode on iOS
This commit is contained in:
parent
cc221bc089
commit
b7119acd3e
|
@ -43,6 +43,10 @@ public abstract class PlatformSupport {
|
|||
Gdx.input.vibrate( millis );
|
||||
}
|
||||
|
||||
public void setHonorSilentSwitch( boolean value ){
|
||||
//does nothing by default
|
||||
}
|
||||
|
||||
//TODO should consider spinning this into its own class, rather than platform support getting ever bigger
|
||||
protected static HashMap<FreeTypeFontGenerator, HashMap<Integer, BitmapFont>> fonts;
|
||||
|
||||
|
|
|
@ -201,6 +201,7 @@ public class SPDSettings extends GameSettings {
|
|||
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_IGNORE_SILENT= "ignore_silent";
|
||||
|
||||
public static void music( boolean value ) {
|
||||
Music.INSTANCE.enable( value );
|
||||
|
@ -237,6 +238,15 @@ public class SPDSettings extends GameSettings {
|
|||
public static int SFXVol() {
|
||||
return getInt( KEY_SFX_VOL, 10, 0, 10 );
|
||||
}
|
||||
|
||||
public static void ignoreSilentMode( boolean value ){
|
||||
put( KEY_IGNORE_SILENT, value);
|
||||
Game.platform.setHonorSilentSwitch(!value);
|
||||
}
|
||||
|
||||
public static boolean ignoreSilentMode(){
|
||||
return getBoolean( KEY_IGNORE_SILENT, false);
|
||||
}
|
||||
|
||||
//Languages and Font
|
||||
|
||||
|
|
|
@ -634,6 +634,8 @@ public class WndSettings extends WndTabbed {
|
|||
ColorBlock sep2;
|
||||
OptionSlider optSFX;
|
||||
CheckBox chkMuteSFX;
|
||||
ColorBlock sep3;
|
||||
CheckBox chkIgnoreSilent;
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
|
@ -695,6 +697,23 @@ public class WndSettings extends WndTabbed {
|
|||
};
|
||||
chkMuteSFX.checked(!SPDSettings.soundFx());
|
||||
add( chkMuteSFX );
|
||||
|
||||
//TODO translate for v1.2.0!
|
||||
if (DeviceCompat.isiOS() && Messages.lang() == Languages.ENGLISH){
|
||||
|
||||
sep3 = new ColorBlock(1, 1, 0xFF000000);
|
||||
add(sep3);
|
||||
|
||||
chkIgnoreSilent = new CheckBox( "Ignore Silent Mode" ){
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
SPDSettings.ignoreSilentMode(checked());
|
||||
}
|
||||
};
|
||||
chkIgnoreSilent.checked(SPDSettings.ignoreSilentMode());
|
||||
add(chkIgnoreSilent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -703,16 +722,36 @@ public class WndSettings extends WndTabbed {
|
|||
sep1.size(width, 1);
|
||||
sep1.y = title.bottom() + 2*GAP;
|
||||
|
||||
optMusic.setRect(0, sep1.y + 1 + GAP, width, SLIDER_HEIGHT);
|
||||
chkMusicMute.setRect(0, optMusic.bottom() + GAP, width, BTN_HEIGHT);
|
||||
if (width > 200) {
|
||||
optMusic.setRect(0, sep1.y + 1 + GAP, width/2-1, SLIDER_HEIGHT);
|
||||
chkMusicMute.setRect(0, optMusic.bottom() + GAP, width/2-1, BTN_HEIGHT);
|
||||
|
||||
sep2.size(width, 1);
|
||||
sep2.y = chkMusicMute.bottom() + GAP;
|
||||
sep2.size(width, 1);
|
||||
sep2.y = sep1.y; //just have them overlap
|
||||
|
||||
optSFX.setRect(0, sep2.y + 1 + GAP, width, SLIDER_HEIGHT);
|
||||
chkMuteSFX.setRect(0, optSFX.bottom() + GAP, width, BTN_HEIGHT);
|
||||
optSFX.setRect(optMusic.right()+2, sep2.y + 1 + GAP, width/2-1, SLIDER_HEIGHT);
|
||||
chkMuteSFX.setRect(chkMusicMute.right()+2, optSFX.bottom() + GAP, width/2-1, BTN_HEIGHT);
|
||||
|
||||
} else {
|
||||
optMusic.setRect(0, sep1.y + 1 + GAP, width, SLIDER_HEIGHT);
|
||||
chkMusicMute.setRect(0, optMusic.bottom() + GAP, width, BTN_HEIGHT);
|
||||
|
||||
sep2.size(width, 1);
|
||||
sep2.y = chkMusicMute.bottom() + GAP;
|
||||
|
||||
optSFX.setRect(0, sep2.y + 1 + GAP, width, SLIDER_HEIGHT);
|
||||
chkMuteSFX.setRect(0, optSFX.bottom() + GAP, width, BTN_HEIGHT);
|
||||
}
|
||||
|
||||
height = chkMuteSFX.bottom();
|
||||
|
||||
if (chkIgnoreSilent != null){
|
||||
sep3.size(width, 1);
|
||||
sep3.y = chkMuteSFX.bottom() + GAP;
|
||||
|
||||
chkIgnoreSilent.setRect(0, sep3.y + 1 + GAP, width, BTN_HEIGHT);
|
||||
height = chkIgnoreSilent.bottom();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.shatteredpixel.shatteredpixeldungeon.ios;
|
|||
import com.badlogic.gdx.Files;
|
||||
import com.badlogic.gdx.backends.iosrobovm.IOSApplication;
|
||||
import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration;
|
||||
import com.badlogic.gdx.backends.iosrobovm.IOSPreferences;
|
||||
import com.badlogic.gdx.graphics.glutils.HdpiMode;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
|
@ -18,12 +19,17 @@ import org.robovm.apple.foundation.NSAutoreleasePool;
|
|||
import org.robovm.apple.foundation.NSBundle;
|
||||
import org.robovm.apple.foundation.NSDictionary;
|
||||
import org.robovm.apple.foundation.NSException;
|
||||
import org.robovm.apple.foundation.NSMutableDictionary;
|
||||
import org.robovm.apple.foundation.NSObject;
|
||||
import org.robovm.apple.foundation.NSProcessInfo;
|
||||
import org.robovm.apple.foundation.NSString;
|
||||
import org.robovm.apple.glkit.GLKViewDrawableColorFormat;
|
||||
import org.robovm.apple.glkit.GLKViewDrawableDepthFormat;
|
||||
import org.robovm.apple.uikit.UIApplication;
|
||||
import org.robovm.apple.uikit.UIScreen;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class IOSLauncher extends IOSApplication.Delegate {
|
||||
@Override
|
||||
protected IOSApplication createApplication() {
|
||||
|
@ -55,12 +61,32 @@ public class IOSLauncher extends IOSApplication.Delegate {
|
|||
|
||||
FileUtils.setDefaultFileProperties(Files.FileType.Local, "");
|
||||
|
||||
//sets up preferences early so they can be read.
|
||||
//this is mostly a copy-paste from IOSApplication.getPreferences
|
||||
File libraryPath = new File(System.getenv("HOME"), "Library");
|
||||
File finalPath = new File(libraryPath, SPDSettings.DEFAULT_PREFS_FILE + ".plist");
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
NSMutableDictionary<NSString, NSObject> nsDictionary = (NSMutableDictionary<NSString, NSObject>)NSMutableDictionary
|
||||
.read(finalPath);
|
||||
|
||||
// if it fails to get an existing dictionary, create a new one.
|
||||
if (nsDictionary == null) {
|
||||
nsDictionary = new NSMutableDictionary<NSString, NSObject>();
|
||||
nsDictionary.write(finalPath, false);
|
||||
}
|
||||
SPDSettings.set(new IOSPreferences(nsDictionary, finalPath.getAbsolutePath()));
|
||||
//end of prefs setup
|
||||
|
||||
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
|
||||
|
||||
config.colorFormat = GLKViewDrawableColorFormat.RGBA8888;
|
||||
config.depthFormat = GLKViewDrawableDepthFormat.None;
|
||||
config.hdpiMode = HdpiMode.Pixels;
|
||||
|
||||
config.hideHomeIndicator = SPDSettings.fullscreen();
|
||||
config.overrideRingerSwitch = SPDSettings.ignoreSilentMode();
|
||||
|
||||
if (NSProcessInfo.getSharedProcessInfo().getOperatingSystemVersion().getMajorVersion() >= 11) {
|
||||
config.preferredFramesPerSecond = (int)(UIScreen.getMainScreen().getMaximumFramesPerSecond());
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.shatteredpixel.shatteredpixeldungeon.ios;
|
|||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.backends.iosrobovm.IOSGraphics;
|
||||
import com.badlogic.gdx.backends.iosrobovm.objectal.OALSimpleAudio;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
|
@ -66,6 +67,11 @@ public class IOSPlatformSupport extends PlatformSupport {
|
|||
AudioServices.playSystemSound(1520);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHonorSilentSwitch( boolean value ) {
|
||||
OALSimpleAudio.sharedInstance().setHonorSilentSwitch(value);
|
||||
}
|
||||
|
||||
/* FONT SUPPORT */
|
||||
|
||||
//custom pixel font, for use with Latin and Cyrillic languages
|
||||
|
|
Loading…
Reference in New Issue
Block a user