launchGame.m 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  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. __auto_type args = [NSMutableArray arrayWithCapacity:argc];
  28. for (int i = 0; i < argc; ++i)
  29. [args addObject:@(argv[i])];
  30. [NSNotificationCenter.defaultCenter postNotificationName:@"StartGame" object:nil userInfo:@{@"args": args}];
  31. }