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
+3 -2
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>en</string>
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
@@ -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>
@@ -114,5 +115,5 @@
</dict> </dict>
</dict> </dict>
</array> </array>
</dict> </dict>
</plist> </plist>
@@ -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());