From 17d8c646f2d0dccf50e6a8e7dc39c46e26d1a66a Mon Sep 17 00:00:00 2001 From: nordsoft Date: Tue, 8 Nov 2022 05:02:26 +0400 Subject: [PATCH] Command line arguments for ios --- client/ios/main.m | 8 +++++++- launcher/ios/main.m | 8 ++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/client/ios/main.m b/client/ios/main.m index dbba2cef3..11c39725e 100644 --- a/client/ios/main.m +++ b/client/ios/main.m @@ -50,7 +50,13 @@ int client_main(int argc, char * argv[]) id __block startGameObserver = [NSNotificationCenter.defaultCenter addObserverForName:@"StartGame" object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { [NSNotificationCenter.defaultCenter removeObserver:startGameObserver]; startGameObserver = nil; - startSDLManually(argc, argv); + + __auto_type args = note.userInfo[@"args"]; + char * newArgv[args.count]; + [args enumerateObjectsUsingBlock:^(NSString * obj, NSUInteger idx, BOOL * stop) { + newArgv[idx] = obj.UTF8String; + }]; + startSDLManually(args.count, newArgv); }]; return qt_main_wrapper(argc, argv); } diff --git a/launcher/ios/main.m b/launcher/ios/main.m index 5f14d4ff1..fae8adf7b 100644 --- a/launcher/ios/main.m +++ b/launcher/ios/main.m @@ -26,5 +26,9 @@ void launchGame(int argc, char * argv[]) { qtNativeWindow.windowScene = nil; #endif } - [NSNotificationCenter.defaultCenter postNotificationName:@"StartGame" object:nil]; -} + + __auto_type args = [NSMutableArray arrayWithCapacity:argc]; + for (int i = 0; i < argc; ++i) + [arr addObject:@(argv[i])]; + [NSNotificationCenter.defaultCenter postNotificationName:@"StartGame" object:nil userInfo:@{@"args": args}]; +} \ No newline at end of file