--- a/src/video/uikit/SDL_uikitappdelegate.m Wed Oct 03 20:49:16 2012 -0700
+++ b/src/video/uikit/SDL_uikitappdelegate.m Thu Oct 04 02:13:12 2012 -0700
@@ -22,16 +22,16 @@
#if SDL_VIDEO_DRIVER_UIKIT
-#import "../SDL_sysvideo.h"
-#import "SDL_assert.h"
-#import "SDL_hints.h"
-#import "../../SDL_hints_c.h"
-#import "SDL_system.h"
+#include "../SDL_sysvideo.h"
+#include "SDL_assert.h"
+#include "SDL_hints.h"
+#include "../../SDL_hints_c.h"
+#include "SDL_system.h"
-#import "SDL_uikitappdelegate.h"
-#import "SDL_uikitopenglview.h"
-#import "../../events/SDL_events_c.h"
-#import "jumphack.h"
+#include "SDL_uikitappdelegate.h"
+#include "SDL_uikitmodes.h"
+#include "../../events/SDL_events_c.h"
+#include "jumphack.h"
#ifdef main
#undef main
@@ -41,6 +41,7 @@
static int forward_argc;
static char **forward_argv;
static int exit_status;
+static UIWindow *launch_window;
int main(int argc, char **argv)
{
@@ -77,6 +78,87 @@
[UIApplication sharedApplication].idleTimerDisabled = disable;
}
+@interface SDL_splashviewcontroller : UIViewController {
+ UIImageView *splash;
+ UIImage *splashPortrait;
+ UIImage *splashLandscape;
+}
+
+- (void)updateSplashImage:(UIInterfaceOrientation)interfaceOrientation;
+@end
+
+@implementation SDL_splashviewcontroller
+
+- (id)init
+{
+ self = [super init];
+ if (self == nil) {
+ return nil;
+ }
+
+ self->splash = [[UIImageView alloc] init];
+ [self setView:self->splash];
+
+ self->splashPortrait = [UIImage imageNamed:@"Default.png"];
+ self->splashLandscape = [UIImage imageNamed:@"Default-Landscape.png"];
+ if (!self->splashLandscape && self->splashPortrait)
+ {
+ self->splashLandscape = [[UIImage alloc] initWithCGImage: self->splashPortrait.CGImage
+ scale: 1.0
+ orientation: UIImageOrientationRight];
+ }
+ if (self->splashPortrait) {
+ [self->splashPortrait retain];
+ }
+ if (self->splashLandscape) {
+ [self->splashLandscape retain];
+ }
+
+ [self updateSplashImage:[[UIApplication sharedApplication] statusBarOrientation]];
+
+ return self;
+}
+
+- (NSUInteger)supportedInterfaceOrientations
+{
+ NSUInteger orientationMask = UIInterfaceOrientationMaskAll;
+
+ // Don't allow upside-down orientation on the phone, so answering calls is in the natural orientation
+ if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
+ orientationMask &= ~UIInterfaceOrientationMaskPortraitUpsideDown;
+ }
+ return orientationMask;
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient
+{
+ NSUInteger orientationMask = [self supportedInterfaceOrientations];
+ return (orientationMask & (1 << orient));
+}
+
+- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
+{
+ [self updateSplashImage:interfaceOrientation];
+}
+
+- (void)updateSplashImage:(UIInterfaceOrientation)interfaceOrientation
+{
+ UIImage *image;
+
+ if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
+ image = self->splashLandscape;
+ } else {
+ image = self->splashPortrait;
+ }
+ if (image)
+ {
+ splash.image = image;
+ }
+}
+
+@end
+
+
@implementation SDLUIKitDelegate
/* convenience method */
@@ -106,6 +188,12 @@
exit_status = SDL_main(forward_argc, forward_argv);
SDL_iPhoneSetEventPump(SDL_FALSE);
+ /* If we showed a splash image, clean it up */
+ if (launch_window) {
+ [launch_window release];
+ launch_window = NULL;
+ }
+
/* exit, passing the return status from the user's application */
// We don't actually exit to support applications that do setup in
// their main function and then allow the Cocoa event loop to run.
@@ -114,6 +202,14 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
+ /* Keep the launch image up until we set a video mode */
+ launch_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+
+ UIViewController *splashViewController = [[SDL_splashviewcontroller alloc] init];
+ launch_window.rootViewController = splashViewController;
+ [launch_window addSubview:splashViewController.view];
+ [launch_window makeKeyAndVisible];
+
/* Set working directory to resource path */
[[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]];
--- a/src/video/uikit/SDL_uikitvideo.h Wed Oct 03 20:49:16 2012 -0700
+++ b/src/video/uikit/SDL_uikitvideo.h Thu Oct 04 02:13:12 2012 -0700
@@ -25,6 +25,21 @@
#include "../SDL_sysvideo.h"
+#ifndef __IPHONE_6_0
+// This enum isn't available in older SDKs, but we use it for our own purposes on iOS 5.1 and for the system on iOS 6.0
+enum UIInterfaceOrientationMask
+{
+ UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait),
+ UIInterfaceOrientationMaskLandscapeLeft = (1 << UIInterfaceOrientationLandscapeLeft),
+ UIInterfaceOrientationMaskLandscapeRight = (1 << UIInterfaceOrientationLandscapeRight),
+ UIInterfaceOrientationMaskPortraitUpsideDown = (1 << UIInterfaceOrientationPortraitUpsideDown),
+ UIInterfaceOrientationMaskLandscape = (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
+ UIInterfaceOrientationMaskAll = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown),
+ UIInterfaceOrientationMaskAllButUpsideDown = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
+};
+#endif // !__IPHONE_6_0
+
+
#endif /* _SDL_uikitvideo_h */
/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/uikit/SDL_uikitviewcontroller.m Wed Oct 03 20:49:16 2012 -0700
+++ b/src/video/uikit/SDL_uikitviewcontroller.m Thu Oct 04 02:13:12 2012 -0700
@@ -34,21 +34,6 @@
#include "SDL_uikitwindow.h"
-#ifndef __IPHONE_6_0
-// This enum isn't available in older SDKs, but we use it for our own purposes on iOS 5.1 and for the system on iOS 6.0
-enum UIInterfaceOrientationMask
-{
- UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait),
- UIInterfaceOrientationMaskLandscapeLeft = (1 << UIInterfaceOrientationLandscapeLeft),
- UIInterfaceOrientationMaskLandscapeRight = (1 << UIInterfaceOrientationLandscapeRight),
- UIInterfaceOrientationMaskPortraitUpsideDown = (1 << UIInterfaceOrientationPortraitUpsideDown),
- UIInterfaceOrientationMaskLandscape = (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
- UIInterfaceOrientationMaskAll = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown),
- UIInterfaceOrientationMaskAllButUpsideDown = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
-};
-#endif // !__IPHONE_6_0
-
-
@implementation SDL_uikitviewcontroller
@synthesize window;