2021-03-16 22:32:07 +02:00
|
|
|
/*
|
2022-08-05 13:32:29 +02:00
|
|
|
* startSDL.mm, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2022-08-07 07:58:04 +02:00
|
|
|
#import "startSDL.h"
|
2022-09-29 11:47:31 +02:00
|
|
|
#import "GameChatKeyboardHandler.h"
|
2021-03-16 22:32:07 +02:00
|
|
|
|
2021-03-21 16:30:34 +02:00
|
|
|
#include "../Global.h"
|
|
|
|
#include "CMT.h"
|
2021-03-22 21:40:19 +02:00
|
|
|
#include "CServerHandler.h"
|
2021-03-21 16:30:34 +02:00
|
|
|
#include "CFocusableHelper.h"
|
2021-03-16 22:32:07 +02:00
|
|
|
|
2022-08-07 07:58:04 +02:00
|
|
|
#include <SDL_main.h>
|
|
|
|
#include <SDL_events.h>
|
|
|
|
#include <SDL_render.h>
|
|
|
|
#include <SDL_system.h>
|
2021-04-19 01:28:29 +02:00
|
|
|
|
2021-03-21 16:30:34 +02:00
|
|
|
#import <UIKit/UIKit.h>
|
2021-03-21 12:15:43 +02:00
|
|
|
|
2021-03-22 21:40:19 +02:00
|
|
|
@interface SDLViewObserver : NSObject <UIGestureRecognizerDelegate>
|
2022-09-29 11:47:31 +02:00
|
|
|
@property (nonatomic, strong) GameChatKeyboardHandler * gameChatHandler;
|
2021-03-16 22:32:07 +02:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation SDLViewObserver
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2022-08-07 07:58:04 +02:00
|
|
|
int startSDL(int argc, char * argv[], BOOL startManually)
|
2021-03-16 22:32:07 +02:00
|
|
|
{
|
2022-08-05 13:32:29 +02:00
|
|
|
@autoreleasepool {
|
|
|
|
auto observer = [SDLViewObserver new];
|
2022-09-29 11:47:31 +02:00
|
|
|
observer.gameChatHandler = [GameChatKeyboardHandler new];
|
2022-08-07 08:31:56 +02:00
|
|
|
|
|
|
|
id textFieldObserver = [NSNotificationCenter.defaultCenter addObserverForName:UITextFieldTextDidEndEditingNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
|
2022-08-05 13:32:29 +02:00
|
|
|
removeFocusFromActiveInput();
|
|
|
|
}];
|
|
|
|
|
2022-08-07 08:31:56 +02:00
|
|
|
int result;
|
|
|
|
if (startManually)
|
|
|
|
{
|
|
|
|
// copied from -[SDLUIKitDelegate postFinishLaunch]
|
|
|
|
SDL_SetMainReady();
|
|
|
|
SDL_iOSSetEventPump(SDL_TRUE);
|
|
|
|
result = SDL_main(argc, argv);
|
|
|
|
SDL_iOSSetEventPump(SDL_FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
result = SDL_UIKitRunApp(argc, argv, SDL_main);
|
|
|
|
|
|
|
|
[NSNotificationCenter.defaultCenter removeObserver:textFieldObserver];
|
2022-08-05 13:32:29 +02:00
|
|
|
return result;
|
|
|
|
}
|
2021-03-16 22:32:07 +02:00
|
|
|
}
|