main.m 1.1 KB

123456789101112131415161718192021222324252627282930
  1. /*
  2. * main.m, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #import <UIKit/UIKit.h>
  11. void launchGame(int argc, char * argv[]) {
  12. @autoreleasepool {
  13. __auto_type app = UIApplication.sharedApplication;
  14. __auto_type qtNativeWindowIndex = [app.windows indexOfObjectPassingTest:^BOOL(__kindof UIWindow * _Nonnull window, NSUInteger idx, BOOL * _Nonnull stop) {
  15. return [NSStringFromClass([window class]) isEqualToString:@"QUIWindow"];
  16. }];
  17. NSCAssert(qtNativeWindowIndex != NSNotFound, @"Qt native window doesn't exist");
  18. __auto_type qtNativeWindow = app.windows[qtNativeWindowIndex];
  19. qtNativeWindow.hidden = YES;
  20. [qtNativeWindow.rootViewController.view removeFromSuperview];
  21. qtNativeWindow.rootViewController = nil;
  22. #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
  23. if (@available(iOS 13.0, *))
  24. qtNativeWindow.windowScene = nil;
  25. #endif
  26. }
  27. [NSNotificationCenter.defaultCenter postNotificationName:@"StartGame" object:nil];
  28. }