mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-01 00:45:26 +02:00
Command line arguments for ios
This commit is contained in:
@ -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) {
|
id __block startGameObserver = [NSNotificationCenter.defaultCenter addObserverForName:@"StartGame" object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
|
||||||
[NSNotificationCenter.defaultCenter removeObserver:startGameObserver];
|
[NSNotificationCenter.defaultCenter removeObserver:startGameObserver];
|
||||||
startGameObserver = nil;
|
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);
|
return qt_main_wrapper(argc, argv);
|
||||||
}
|
}
|
||||||
|
@ -26,5 +26,9 @@ void launchGame(int argc, char * argv[]) {
|
|||||||
qtNativeWindow.windowScene = nil;
|
qtNativeWindow.windowScene = nil;
|
||||||
#endif
|
#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}];
|
||||||
}
|
}
|
Reference in New Issue
Block a user