mirror of https://github.com/encounter/SDL.git
Fixed SDL_HINT_ORIENTATIONS to properly allow disabling custom orientations if the hint is set with no valid orientations.
This commit is contained in:
parent
b21544c1dd
commit
b55be6e7bd
|
@ -69,13 +69,12 @@
|
||||||
- (NSUInteger)supportedInterfaceOrientations
|
- (NSUInteger)supportedInterfaceOrientations
|
||||||
{
|
{
|
||||||
NSUInteger orientationMask = 0;
|
NSUInteger orientationMask = 0;
|
||||||
|
const char *orientationsHint = SDL_GetHint(SDL_HINT_ORIENTATIONS);
|
||||||
|
|
||||||
const char *orientationsCString;
|
if (orientationsHint != NULL) {
|
||||||
if ((orientationsCString = SDL_GetHint(SDL_HINT_ORIENTATIONS)) != NULL) {
|
NSString *orientationsString = [NSString stringWithCString:orientationsHint
|
||||||
BOOL rotate = NO;
|
encoding:NSUTF8StringEncoding];
|
||||||
NSString *orientationsNSString = [NSString stringWithCString:orientationsCString
|
NSArray *orientations = [orientationsString componentsSeparatedByCharactersInSet:
|
||||||
encoding:NSUTF8StringEncoding];
|
|
||||||
NSArray *orientations = [orientationsNSString componentsSeparatedByCharactersInSet:
|
|
||||||
[NSCharacterSet characterSetWithCharactersInString:@" "]];
|
[NSCharacterSet characterSetWithCharactersInString:@" "]];
|
||||||
|
|
||||||
if ([orientations containsObject:@"LandscapeLeft"]) {
|
if ([orientations containsObject:@"LandscapeLeft"]) {
|
||||||
|
@ -90,14 +89,17 @@
|
||||||
if ([orientations containsObject:@"PortraitUpsideDown"]) {
|
if ([orientations containsObject:@"PortraitUpsideDown"]) {
|
||||||
orientationMask |= UIInterfaceOrientationMaskPortraitUpsideDown;
|
orientationMask |= UIInterfaceOrientationMaskPortraitUpsideDown;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else if (self->window->flags & SDL_WINDOW_RESIZABLE) {
|
if (orientationMask == 0 && window->flags & SDL_WINDOW_RESIZABLE) {
|
||||||
orientationMask = UIInterfaceOrientationMaskAll; /* any orientation is okay. */
|
orientationMask = UIInterfaceOrientationMaskAll; /* any orientation is okay. */
|
||||||
} else {
|
}
|
||||||
if (self->window->w >= self->window->h) {
|
|
||||||
|
if (orientationMask == 0) {
|
||||||
|
if (window->w >= window->h) {
|
||||||
orientationMask |= UIInterfaceOrientationMaskLandscape;
|
orientationMask |= UIInterfaceOrientationMaskLandscape;
|
||||||
}
|
}
|
||||||
if (self->window->h >= self->window->w) {
|
if (window->h >= window->w) {
|
||||||
orientationMask |= (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
|
orientationMask |= (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +119,7 @@
|
||||||
|
|
||||||
- (BOOL)prefersStatusBarHidden
|
- (BOOL)prefersStatusBarHidden
|
||||||
{
|
{
|
||||||
if (self->window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
|
if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
|
||||||
return YES;
|
return YES;
|
||||||
} else {
|
} else {
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -129,7 +131,7 @@
|
||||||
#ifdef __IPHONE_7_0
|
#ifdef __IPHONE_7_0
|
||||||
return UIStatusBarStyleLightContent;
|
return UIStatusBarStyleLightContent;
|
||||||
#else
|
#else
|
||||||
/* This is only called in iOS 7+, so the return value isn't important. */
|
/* This method is only used in iOS 7+, so the return value here isn't important. */
|
||||||
return UIStatusBarStyleBlackTranslucent;
|
return UIStatusBarStyleBlackTranslucent;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue