iOS portrait mode support

This commit is contained in:
Anuken
2018-08-16 18:38:43 -04:00
parent 53d35e8c77
commit 6d7941fba4
2 changed files with 127 additions and 109 deletions
+1
View File
@@ -50,6 +50,7 @@
<array> <array>
<string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string> <string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
</array> </array>
<key>CFBundleDocumentTypes</key> <key>CFBundleDocumentTypes</key>
@@ -32,6 +32,8 @@ import static io.anuke.mindustry.Vars.*;
import static org.robovm.apple.foundation.NSPathUtilities.getDocumentsDirectory; import static org.robovm.apple.foundation.NSPathUtilities.getDocumentsDirectory;
public class IOSLauncher extends IOSApplication.Delegate { public class IOSLauncher extends IOSApplication.Delegate {
private boolean forced;
@Override @Override
protected IOSApplication createApplication() { protected IOSApplication createApplication() {
Net.setClientProvider(new KryoClient()); Net.setClientProvider(new KryoClient());
@@ -88,12 +90,27 @@ public class IOSLauncher extends IOSApplication.Delegate {
UIApplication.getSharedApplication().getKeyWindow().getRootViewController() UIApplication.getSharedApplication().getKeyWindow().getRootViewController()
.presentViewController(p, true, () -> io.anuke.ucore.util.Log.info("Success! Presented {0}", to)); .presentViewController(p, true, () -> io.anuke.ucore.util.Log.info("Success! Presented {0}", to));
} }
@Override
public void beginForceLandscape(){
forced = true;
}
@Override
public void endForceLandscape(){
forced = false;
}
}; };
IOSApplicationConfiguration config = new IOSApplicationConfiguration(); IOSApplicationConfiguration config = new IOSApplicationConfiguration();
return new IOSApplication(new Mindustry(), config); return new IOSApplication(new Mindustry(), config);
} }
@Override
public UIInterfaceOrientationMask getSupportedInterfaceOrientations(UIApplication application, UIWindow window){
return forced ? UIInterfaceOrientationMask.Landscape : UIInterfaceOrientationMask.All;
}
@Override @Override
public boolean openURL(UIApplication app, NSURL url, UIApplicationOpenURLOptions options) { public boolean openURL(UIApplication app, NSURL url, UIApplicationOpenURLOptions options) {
System.out.println("Opened URL: " + url.getPath()); System.out.println("Opened URL: " + url.getPath());