1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Command line arguments for ios

This commit is contained in:
nordsoft 2022-11-08 05:02:26 +04:00
parent 97e5fc8a07
commit 17d8c646f2
2 changed files with 13 additions and 3 deletions

View File

@ -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);
}

View File

@ -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}];
}