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

View File

@@ -32,6 +32,8 @@ import static io.anuke.mindustry.Vars.*;
import static org.robovm.apple.foundation.NSPathUtilities.getDocumentsDirectory;
public class IOSLauncher extends IOSApplication.Delegate {
private boolean forced;
@Override
protected IOSApplication createApplication() {
Net.setClientProvider(new KryoClient());
@@ -86,7 +88,17 @@ public class IOSLauncher extends IOSApplication.Delegate {
p.getPopoverPresentationController().setSourceView(UIApplication.getSharedApplication().getKeyWindow().getRootViewController().getView());
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;
}
};
@@ -94,6 +106,11 @@ public class IOSLauncher extends IOSApplication.Delegate {
return new IOSApplication(new Mindustry(), config);
}
@Override
public UIInterfaceOrientationMask getSupportedInterfaceOrientations(UIApplication application, UIWindow window){
return forced ? UIInterfaceOrientationMask.Landscape : UIInterfaceOrientationMask.All;
}
@Override
public boolean openURL(UIApplication app, NSURL url, UIApplicationOpenURLOptions options) {
System.out.println("Opened URL: " + url.getPath());