mirror of https://github.com/encounter/SDL.git
tvOS launch images are now properly supported.
This commit is contained in:
parent
a8b033d7c4
commit
77bacfd72d
|
@ -24,6 +24,7 @@
|
|||
@interface SDLLaunchScreenController : UIViewController
|
||||
|
||||
- (instancetype)init;
|
||||
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;
|
||||
- (void)loadView;
|
||||
|
||||
@end
|
||||
|
|
|
@ -155,29 +155,29 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
|
|||
}
|
||||
|
||||
if (!self.view) {
|
||||
#if !TARGET_OS_TV
|
||||
NSArray *launchimages = [bundle objectForInfoDictionaryKey:@"UILaunchImages"];
|
||||
UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation;
|
||||
NSString *imagename = nil;
|
||||
UIImage *image = nil;
|
||||
|
||||
int screenw = (int)([UIScreen mainScreen].bounds.size.width + 0.5);
|
||||
int screenh = (int)([UIScreen mainScreen].bounds.size.height + 0.5);
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation;
|
||||
|
||||
/* We always want portrait-oriented size, to match UILaunchImageSize. */
|
||||
if (screenw > screenh) {
|
||||
int width = screenw;
|
||||
screenw = screenh;
|
||||
screenh = width;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Xcode 5 introduced a dictionary of launch images in Info.plist. */
|
||||
if (launchimages) {
|
||||
for (NSDictionary *dict in launchimages) {
|
||||
UIInterfaceOrientationMask orientmask = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
|
||||
NSString *minversion = dict[@"UILaunchImageMinimumOSVersion"];
|
||||
NSString *sizestring = dict[@"UILaunchImageSize"];
|
||||
NSString *orientstring = dict[@"UILaunchImageOrientation"];
|
||||
NSString *minversion = dict[@"UILaunchImageMinimumOSVersion"];
|
||||
NSString *sizestring = dict[@"UILaunchImageSize"];
|
||||
|
||||
/* Ignore this image if the current version is too low. */
|
||||
if (minversion && !UIKit_IsSystemVersionAtLeast(minversion.doubleValue)) {
|
||||
|
@ -192,6 +192,10 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
|
|||
}
|
||||
}
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
UIInterfaceOrientationMask orientmask = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
|
||||
NSString *orientstring = dict[@"UILaunchImageOrientation"];
|
||||
|
||||
if (orientstring) {
|
||||
if ([orientstring isEqualToString:@"PortraitUpsideDown"]) {
|
||||
orientmask = UIInterfaceOrientationMaskPortraitUpsideDown;
|
||||
|
@ -208,6 +212,7 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
|
|||
if ((orientmask & (1 << curorient)) == 0) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
imagename = dict[@"UILaunchImageName"];
|
||||
}
|
||||
|
@ -215,7 +220,9 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
|
|||
if (imagename) {
|
||||
image = [UIImage imageNamed:imagename];
|
||||
}
|
||||
} else {
|
||||
}
|
||||
#if !TARGET_OS_TV
|
||||
else {
|
||||
imagename = [bundle objectForInfoDictionaryKey:@"UILaunchImageFile"];
|
||||
|
||||
if (imagename) {
|
||||
|
@ -226,11 +233,13 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
|
|||
image = SDL_LoadLaunchImageNamed(@"Default", screenh);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (image) {
|
||||
UIImageView *view = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
||||
UIImageOrientation imageorient = UIImageOrientationUp;
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
/* Bugs observed / workaround tested in iOS 8.3, 7.1, and 6.1. */
|
||||
if (UIInterfaceOrientationIsLandscape(curorient)) {
|
||||
if (atleastiOS8 && image.size.width < image.size.height) {
|
||||
|
@ -254,15 +263,13 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Create the properly oriented image. */
|
||||
view.image = [[UIImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:imageorient];
|
||||
|
||||
self.view = view;
|
||||
}
|
||||
#else /* !TARGET_OS_TV */
|
||||
return nil;
|
||||
#endif
|
||||
}
|
||||
|
||||
return self;
|
||||
|
@ -363,10 +370,11 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
|
|||
* called), so we show the launch screen programmatically until the first
|
||||
* time events are pumped. */
|
||||
UIViewController *vc = nil;
|
||||
NSString *screenname = nil;
|
||||
|
||||
/* TODO: Try to load the 1080p launch image on tvOS. */
|
||||
/* tvOS only uses a plain launch image. */
|
||||
#if !TARGET_OS_TV
|
||||
NSString *screenname = [bundle objectForInfoDictionaryKey:@"UILaunchStoryboardName"];
|
||||
screenname = [bundle objectForInfoDictionaryKey:@"UILaunchStoryboardName"];
|
||||
|
||||
if (screenname && UIKit_IsSystemVersionAtLeast(8.0)) {
|
||||
@try {
|
||||
|
@ -380,11 +388,11 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
|
|||
/* Do nothing (there's more code to execute below). */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (vc == nil) {
|
||||
vc = [[SDLLaunchScreenController alloc] initWithNibName:screenname bundle:bundle];
|
||||
}
|
||||
#endif
|
||||
|
||||
if (vc.view) {
|
||||
launchWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
||||
|
|
Loading…
Reference in New Issue