From 5d8a136470be8155e047571518fb1cab6bac7aee Mon Sep 17 00:00:00 2001 From: khanhduytran0 Date: Sat, 16 Jul 2022 13:27:25 +0700 Subject: [PATCH] SurfaceViewController is now always the root vc Before launching game, SurfaceViewController is set to UIWindow.rootViewController, making it similar to "Restart before launching" in order to *attempt* to find out why touchscreen input does not work on certain devices. The restart option is still kept for debugging purpose. Some other tiny code tweaks --- Natives/MinecraftResourceUtils.m | 11 ++++------- Natives/SurfaceViewController.m | 9 +++------ Natives/ios_uikit_bridge.m | 15 ++++++++++++--- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Natives/MinecraftResourceUtils.m b/Natives/MinecraftResourceUtils.m index 743245de..dd2d5bc4 100644 --- a/Natives/MinecraftResourceUtils.m +++ b/Natives/MinecraftResourceUtils.m @@ -39,14 +39,11 @@ static AFURLSessionManager* manager; // Check if the account has permission to download + (BOOL)checkAccessWithDialog:(BOOL)show { // for now - if ([BaseAuthenticator.current.authData[@"username"] hasPrefix:@"Demo."] || BaseAuthenticator.current.authData[@"xboxGamertag"] != nil) { - return YES; - } else { - if (show) { - showDialog(viewController, @"Error", @"Minecraft can't be legally installed when logged in with a local account. Please switch to an online account to continue."); - } - return NO; + BOOL accessible = [BaseAuthenticator.current.authData[@"username"] hasPrefix:@"Demo."] || BaseAuthenticator.current.authData[@"xboxGamertag"] != nil; + if (!accessible && show) { + showDialog(viewController, @"Error", @"Minecraft can't be legally installed when logged in with a local account. Please switch to an online account to continue."); } + return accessible; } // Check SHA of the file diff --git a/Natives/SurfaceViewController.m b/Natives/SurfaceViewController.m index 60d5adfe..a98ef45b 100644 --- a/Natives/SurfaceViewController.m +++ b/Natives/SurfaceViewController.m @@ -113,8 +113,6 @@ BOOL slideableHotbar; CGRect screenBounds = [[UIScreen mainScreen] bounds]; CGFloat screenScale = [[UIScreen mainScreen] scale]; - UIEdgeInsets insets = UIApplication.sharedApplication.windows.firstObject.safeAreaInsets; - resolutionScale = ((NSNumber *)getPreference(@"resolution")).floatValue / 100.0; slideableHotbar = [getPreference(@"slideable_hotbar") boolValue]; @@ -630,10 +628,8 @@ CGPoint lastCenterPoint; - (void)surfaceOnHover:(UIHoverGestureRecognizer *)sender API_AVAILABLE(ios(13.0)) { if (@available(iOS 13.0, *)) { - if (@available(iOS 14.0, *)) { - if(isGrabbing) { // Can't put into above if statement - return; - } + if (@available(iOS 14.0, *) && isGrabbing) { + return; } CGPoint point = [sender locationInView:self.rootView]; // NSLog(@"Mouse move!!"); @@ -864,6 +860,7 @@ int currentVisibility = 1; if (!held) { CallbackBridge_nativeSendScroll(0.0, -1.0); } + break; case SPECIALBTN_VIRTUALMOUSE: if (!isGrabbing && !held) { diff --git a/Natives/ios_uikit_bridge.m b/Natives/ios_uikit_bridge.m index 93d9861a..86ccb40e 100644 --- a/Natives/ios_uikit_bridge.m +++ b/Natives/ios_uikit_bridge.m @@ -121,9 +121,18 @@ void UIKit_launchMinecraftSurfaceVC() { usleep(1000); exit(0); } else { - SurfaceViewController *vc = [[SurfaceViewController alloc] init]; - vc.modalPresentationStyle = UIModalPresentationFullScreen; - [viewController.navigationController pushViewController:vc animated:YES]; + id delegate = UIApplication.sharedApplication.delegate; + if (@available(iOS 13.0, *)) { + delegate = UIApplication.sharedApplication.connectedScenes.anyObject.delegate; + } + UIWindow *window = [delegate window]; + [UIView animateWithDuration:0.2 animations:^{ + window.rootViewController.view.alpha = 0; + } completion:^(BOOL b){ + [window resignKeyWindow]; + window.rootViewController = [[SurfaceViewController alloc] init]; + [window makeKeyAndVisible]; + }]; } }); }