From 9fb18b3b45a2aa9e37c6f5aab19c8574833ad085 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 11 Jun 2025 14:24:49 -0400 Subject: [PATCH] v3.1.1: fixes to improve experience on modern iOS versions: - fixed URLs not opening on modern iOS versions - fixed haptics not working on modern iOS versions - switched to metalangle backend, which 'should' allow for 120fps These all require some user testing! --- ios/build.gradle | 2 +- .../shatteredpixeldungeon/ios/IOSLauncher.java | 9 +++++---- .../ios/IOSPlatformSupport.java | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ios/build.gradle b/ios/build.gradle index 46797485a..5eecaf5e7 100644 --- a/ios/build.gradle +++ b/ios/build.gradle @@ -46,7 +46,7 @@ dependencies { implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" implementation "com.mobidevelop.robovm:robovm-rt:$robovmVersion" implementation "com.mobidevelop.robovm:robovm-cocoatouch:$robovmVersion" - implementation "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion" + implementation "com.badlogicgames.gdx:gdx-backend-robovm-metalangle:$gdxVersion" implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios" implementation "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios" implementation "com.badlogicgames.gdx-controllers:gdx-controllers-ios:$gdxControllersVersion" diff --git a/ios/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ios/IOSLauncher.java b/ios/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ios/IOSLauncher.java index ff32e53f6..ddb18428d 100644 --- a/ios/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ios/IOSLauncher.java +++ b/ios/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ios/IOSLauncher.java @@ -25,6 +25,8 @@ 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.backends.iosrobovm.bindings.metalangle.MGLDrawableColorFormat; +import com.badlogic.gdx.backends.iosrobovm.bindings.metalangle.MGLDrawableDepthFormat; import com.badlogic.gdx.graphics.glutils.HdpiMode; import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; @@ -42,8 +44,6 @@ import org.robovm.apple.foundation.NSException; import org.robovm.apple.foundation.NSMutableDictionary; import org.robovm.apple.foundation.NSObject; 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 java.io.File; @@ -94,8 +94,8 @@ public class IOSLauncher extends IOSApplication.Delegate { IOSApplicationConfiguration config = new IOSApplicationConfiguration(); - config.colorFormat = GLKViewDrawableColorFormat.RGBA8888; - config.depthFormat = GLKViewDrawableDepthFormat.None; + config.colorFormat = MGLDrawableColorFormat.RGBA8888; + config.depthFormat = MGLDrawableDepthFormat.None; config.hdpiMode = HdpiMode.Pixels; config.hideHomeIndicator = SPDSettings.fullscreen(); @@ -110,6 +110,7 @@ public class IOSLauncher extends IOSApplication.Delegate { UIApplication.getSharedApplication().setStatusBarHidden(true); } + config.useHaptics = true; config.useAccelerometer = false; config.useCompass = false; diff --git a/ios/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ios/IOSPlatformSupport.java b/ios/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ios/IOSPlatformSupport.java index e1165e12f..f9e8ef198 100644 --- a/ios/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ios/IOSPlatformSupport.java +++ b/ios/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ios/IOSPlatformSupport.java @@ -35,15 +35,30 @@ import com.watabou.noosa.Game; import com.watabou.utils.PlatformSupport; import org.robovm.apple.audiotoolbox.AudioServices; +import org.robovm.apple.foundation.NSURL; import org.robovm.apple.systemconfiguration.SCNetworkReachability; import org.robovm.apple.systemconfiguration.SCNetworkReachabilityFlags; import org.robovm.apple.uikit.UIApplication; +import org.robovm.apple.uikit.UIApplicationOpenURLOptions; import java.util.HashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; public class IOSPlatformSupport extends PlatformSupport { + + @Override + public boolean openURI( String uri ){ + //backported from libGDX 1.13.1, required for opening URLs on modern iOS + UIApplication uiApp = UIApplication.getSharedApplication(); + NSURL url = new NSURL(uri); + if (uiApp.canOpenURL(url)) { + uiApp.openURL(url, new UIApplicationOpenURLOptions(), null); + return true; + } + return false; + } + @Override public void updateDisplaySize() { //non-zero safe insets on left/top/right means device has a notch, show status bar