@@ -64,11 +64,37 @@ + (ViewController *)viewController {
64
64
return mainViewController;
65
65
}
66
66
67
- - (BOOL )application : (UIApplication *)application didFinishLaunchingWithOptions : (NSDictionary *)launchOptions {
68
- // Create a full-screen window
69
- CGRect windowBounds = [[UIScreen mainScreen ] bounds ];
70
- self.window = [[UIWindow alloc ] initWithFrame: windowBounds];
67
+ static AppDelegate *delegate_singleton = nil ;
68
+
69
+ + (AppDelegate *)getSingleton {
70
+ if (!delegate_singleton) {
71
+ delegate_singleton = [AppDelegate new ];
72
+ }
73
+ return delegate_singleton;
74
+ }
75
+
76
+ - (void )createViewController {
77
+ ViewController *viewController = [[ViewController alloc ] init ];
78
+ viewController.godotView .useCADisplayLink = bool (GLOBAL_DEF (" display.iOS/use_cadisplaylink" , true )) ? YES : NO ;
79
+ viewController.godotView .renderingInterval = 1.0 / kRenderingFrequency ;
80
+
81
+ self.window .rootViewController = viewController;
82
+
83
+ // Show the window
84
+ [self .window makeKeyAndVisible ];
85
+
86
+ mainViewController = viewController;
87
+ }
88
+
89
+ - (void )scene : (UIScene *)scene willConnectToSession : (UISceneSession *)session options : (UISceneConnectionOptions *)connectionOptions API_AVAILABLE(ios(13.0 ), tvos(13.0 ), visionos(1.0 )) {
90
+ if ([scene isKindOfClass: [UIWindowScene class ]]) {
91
+ UIWindowScene *window_scene = (UIWindowScene *)scene;
92
+ self.window = [[UIWindow alloc ] initWithWindowScene: window_scene];
93
+ [self createViewController ];
94
+ }
95
+ }
71
96
97
+ - (BOOL )application : (UIApplication *)application didFinishLaunchingWithOptions : (NSDictionary *)launchOptions {
72
98
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory,
73
99
NSUserDomainMask, YES );
74
100
NSString *documentsDirectory = [paths objectAtIndex: 0 ];
@@ -83,27 +109,21 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
83
109
return FALSE ;
84
110
}
85
111
86
- // WARNING: We must *always* create the GodotView after we have constructed the
87
- // OS with iphone_main. This allows the GodotView to access project settings so
88
- // it can properly initialize the OpenGL context
89
-
90
- ViewController *viewController = [[ViewController alloc ] init ];
91
- viewController.godotView .useCADisplayLink = bool (GLOBAL_DEF (" display.iOS/use_cadisplaylink" , true )) ? YES : NO ;
92
- viewController.godotView .renderingInterval = 1.0 / kRenderingFrequency ;
93
-
94
- self.window .rootViewController = viewController;
95
-
96
- // Show the window
97
- [self .window makeKeyAndVisible ];
112
+ if (@available (iOS 13 , tvOS 13 , *)) {
113
+ // NOP
114
+ } else {
115
+ // Create a full-screen window
116
+ CGRect windowBounds = [[UIScreen mainScreen ] bounds ];
117
+ self.window = [[UIWindow alloc ] initWithFrame: windowBounds];
118
+ [self createViewController ];
119
+ }
98
120
99
121
[[NSNotificationCenter defaultCenter ]
100
122
addObserver: self
101
123
selector: @selector (onAudioInterruption: )
102
124
name: AVAudioSessionInterruptionNotification
103
125
object: [AVAudioSession sharedInstance ]];
104
126
105
- mainViewController = viewController;
106
-
107
127
int sessionCategorySetting = GLOBAL_GET (" audio/general/ios/session_category" );
108
128
109
129
// Initialize with default Ambient category.
@@ -166,22 +186,42 @@ - (void)applicationWillTerminate:(UIApplication *)application {
166
186
// if you open the app list without switching to another app or open/close the
167
187
// notification panel by swiping from the upper part of the screen.
168
188
189
+ - (void )sceneDidDisconnect : (UIScene *)scene API_AVAILABLE(ios(13.0 ), tvos(13.0 ), visionos(1.0 )) {
190
+ OSIPhone::get_singleton ()->on_focus_out ();
191
+ }
192
+
169
193
- (void )applicationWillResignActive : (UIApplication *)application {
170
194
OSIPhone::get_singleton ()->on_focus_out ();
171
195
}
172
196
197
+ - (void )sceneWillResignActive : (UIScene *)scene API_AVAILABLE(ios(13.0 ), tvos(13.0 ), visionos(1.0 )) {
198
+ OSIPhone::get_singleton ()->on_focus_out ();
199
+ }
200
+
173
201
- (void )applicationDidBecomeActive : (UIApplication *)application {
174
202
OSIPhone::get_singleton ()->on_focus_in ();
175
203
}
176
204
205
+ - (void )sceneDidBecomeActive : (UIScene *)scene API_AVAILABLE(ios(13.0 ), tvos(13.0 ), visionos(1.0 )) {
206
+ OSIPhone::get_singleton ()->on_focus_in ();
207
+ }
208
+
177
209
- (void )applicationDidEnterBackground : (UIApplication *)application {
178
210
OSIPhone::get_singleton ()->on_enter_background ();
179
211
}
180
212
213
+ - (void )sceneDidEnterBackground : (UIScene *)scene API_AVAILABLE(ios(13.0 ), tvos(13.0 ), visionos(1.0 )) {
214
+ OSIPhone::get_singleton ()->on_enter_background ();
215
+ }
216
+
181
217
- (void )applicationWillEnterForeground : (UIApplication *)application {
182
218
OSIPhone::get_singleton ()->on_exit_background ();
183
219
}
184
220
221
+ - (void )sceneWillEnterForeground : (UIScene *)scene API_AVAILABLE(ios(13.0 ), tvos(13.0 ), visionos(1.0 )) {
222
+ OSIPhone::get_singleton ()->on_exit_background ();
223
+ }
224
+
185
225
- (void )dealloc {
186
226
self.window = nil ;
187
227
}
0 commit comments