mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-01-09 06:23:21 +08:00
iOS: Fix restarts after the scene change (for backend change etc)
This commit is contained in:
parent
34385ea1fd
commit
3cc57b7a2b
@ -10,7 +10,6 @@
|
||||
@property (strong, nonatomic) UIScreen *screen;
|
||||
@property (nonatomic, strong) NSDictionary *launchOptions;
|
||||
|
||||
- (void)restart:(const char *)args;
|
||||
- (BOOL)launchPPSSPP:(int)argc argv:(char**)argv;
|
||||
|
||||
@end
|
||||
|
||||
@ -3,7 +3,10 @@
|
||||
|
||||
@interface SceneDelegate : UIResponder <UIWindowSceneDelegate>
|
||||
|
||||
- (void)restart:(const char *)args;
|
||||
|
||||
@property (strong, nonatomic) UIWindow * window;
|
||||
@property (strong, nonatomic) UIViewController *viewController;
|
||||
@property (strong, nonatomic) UIWindowScene *windowScene;
|
||||
|
||||
@end
|
||||
|
||||
@ -32,7 +32,12 @@
|
||||
NSLog(@"✅ Window already exists, not creating again!");
|
||||
return;
|
||||
}
|
||||
self.windowScene = windowScene;
|
||||
[self launchPPSSPP];
|
||||
}
|
||||
|
||||
-(void) launchPPSSPP {
|
||||
INFO_LOG(Log::G3D, "SceneDelegate: Launching PPSSPP");
|
||||
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
||||
NSDictionary *launchOptions = appDelegate.launchOptions;
|
||||
|
||||
@ -50,7 +55,7 @@
|
||||
NSString *bundlePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/assets/"];
|
||||
NativeInit(argc, (const char**)argv, documentsPath.UTF8String, bundlePath.UTF8String, NULL);
|
||||
|
||||
self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
|
||||
self.window = [[UIWindow alloc] initWithWindowScene:self.windowScene];
|
||||
// self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
|
||||
// Choose viewcontroller depending on backend.
|
||||
@ -87,7 +92,7 @@
|
||||
NativeShutdown();
|
||||
|
||||
// Launch a fresh instance
|
||||
[self launchPPSSPP:0 argv:nullptr];
|
||||
[self launchPPSSPP];
|
||||
|
||||
// Notify new view controller
|
||||
[self.viewController didBecomeActive];
|
||||
|
||||
14
ios/main.mm
14
ios/main.mm
@ -26,6 +26,7 @@
|
||||
#import "ViewController.h"
|
||||
#import "iOSCoreAudio.h"
|
||||
#import "IAPManager.h"
|
||||
#import "SceneDelegate.h"
|
||||
|
||||
#include "Common/MemoryUtil.h"
|
||||
#include "Common/Audio/AudioBackend.h"
|
||||
@ -439,7 +440,18 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
||||
switch (type) {
|
||||
case SystemRequestType::RESTART_APP:
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[(AppDelegate *)[[UIApplication sharedApplication] delegate] restart:param1.c_str()];
|
||||
// Get the connected scenes
|
||||
NSSet<UIScene *> *scenes = [UIApplication sharedApplication].connectedScenes;
|
||||
|
||||
// Loop through scenes to find a UIWindowScene that is active
|
||||
for (UIScene *scene in scenes) {
|
||||
if ([scene isKindOfClass:[UIWindowScene class]]) {
|
||||
UIWindowScene *windowScene = (UIWindowScene *)scene;
|
||||
SceneDelegate *sceneDelegate = (SceneDelegate *)windowScene.delegate;
|
||||
[sceneDelegate restart:param1.c_str()];
|
||||
break; // call only on the first active scene
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user