IOS: Support building in Xcode 10/iOS 12, and for iPhone X-like devices that have a "safe area"

iOS 12 drops support for libstdc++, so the project needs to be compiled explicitly using libc++.
Support the "safe area" when redrawing the view to leave space for the notch in portrait and
landscape orientations.
This commit is contained in:
Yoshi Sugawara 2018-10-11 17:09:44 -10:00 committed by Thierry Crozat
parent d4087d7902
commit b4bad9100a
15 changed files with 114 additions and 0 deletions

View file

@ -776,6 +776,7 @@ uint getSizeNextPOT(uint size) {
GLfloat ratio = adjustedHeight / adjustedWidth; GLfloat ratio = adjustedHeight / adjustedWidth;
int height = (int)(screenWidth * ratio); int height = (int)(screenWidth * ratio);
//printf("Making rect (%u, %u)\n", screenWidth, height); //printf("Making rect (%u, %u)\n", screenWidth, height);
_gameScreenRect = CGRectMake(0, 0, screenWidth, height); _gameScreenRect = CGRectMake(0, 0, screenWidth, height);
overlayPortraitRatio = (_videoContext.overlayHeight * ratio) / _videoContext.overlayWidth; overlayPortraitRatio = (_videoContext.overlayHeight * ratio) / _videoContext.overlayWidth;
@ -792,6 +793,32 @@ uint getSizeNextPOT(uint size) {
[self setViewTransformation]; [self setViewTransformation];
[self updateMouseCursorScaling]; [self updateMouseCursorScaling];
[self adjustViewFrameForSafeArea];
}
#ifndef __has_builtin
#define __has_builtin(x) 0
#endif
-(void)adjustViewFrameForSafeArea {
#if __has_builtin(__builtin_available)
if ( @available(iOS 11,*) ) {
#else
if ( [[UIApplication sharedApplication] keyWindow] respondsToSelector:@selector(safeAreaInsets) ) {
#endif
CGRect screenSize = [[UIScreen mainScreen] bounds];
UIEdgeInsets inset = [[UIApplication sharedApplication] keyWindow].safeAreaInsets;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
CGRect newFrame = screenSize;
if ( orientation == UIInterfaceOrientationPortrait ) {
newFrame = CGRectMake(screenSize.origin.x, screenSize.origin.y + inset.top, screenSize.size.width, screenSize.size.height - inset.top);
} else if ( orientation == UIInterfaceOrientationLandscapeLeft ) {
newFrame = CGRectMake(screenSize.origin.x, screenSize.origin.y, screenSize.size.width - inset.right, screenSize.size.height);
} else if ( orientation == UIInterfaceOrientationLandscapeRight ) {
newFrame = CGRectMake(screenSize.origin.x + inset.left, screenSize.origin.y, screenSize.size.width - inset.left, screenSize.size.height);
}
self.frame = newFrame;
}
} }
- (void)setViewTransformation { - (void)setViewTransformation {

View file

@ -186,6 +186,7 @@
F9A66C2E1396D36100CEE494 /* Debug */ = { F9A66C2E1396D36100CEE494 /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_CXX_LIBRARY = "libc++";
ENABLE_TESTABILITY = YES; ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
@ -199,6 +200,7 @@
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.5; MACOSX_DEPLOYMENT_TARGET = 10.5;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)";
SDKROOT = macosx; SDKROOT = macosx;
}; };
name = Debug; name = Debug;
@ -206,6 +208,7 @@
F9A66C2F1396D36100CEE494 /* Release */ = { F9A66C2F1396D36100CEE494 /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_CXX_LIBRARY = "libc++";
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_PREPROCESSOR_DEFINITIONS = ( GCC_PREPROCESSOR_DEFINITIONS = (
POSIX, POSIX,
@ -215,6 +218,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.5; MACOSX_DEPLOYMENT_TARGET = 10.5;
OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)";
SDKROOT = macosx; SDKROOT = macosx;
}; };
name = Release; name = Release;
@ -230,6 +234,7 @@
"$(inherited)", "$(inherited)",
DEBUG, DEBUG,
); );
MACOSX_DEPLOYMENT_TARGET = 10.8;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
}; };
name = Debug; name = Debug;
@ -242,6 +247,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)"; GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)";
MACOSX_DEPLOYMENT_TARGET = 10.8;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
}; };
name = Release; name = Release;

View file

@ -1,5 +1,15 @@
{ {
"images" : [ "images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{ {
"size" : "29x29", "size" : "29x29",
"idiom" : "iphone", "idiom" : "iphone",
@ -36,6 +46,16 @@
"filename" : "icon4-60@3x.png", "filename" : "icon4-60@3x.png",
"scale" : "3x" "scale" : "3x"
}, },
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{ {
"size" : "29x29", "size" : "29x29",
"idiom" : "ipad", "idiom" : "ipad",
@ -77,6 +97,11 @@
"idiom" : "ipad", "idiom" : "ipad",
"filename" : "icon4-83.5@2x.png", "filename" : "icon4-83.5@2x.png",
"scale" : "2x" "scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
} }
], ],
"info" : { "info" : {

View file

@ -1,5 +1,59 @@
{ {
"images" : [ "images" : [
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "2688h",
"filename" : "ScummVM-splash-1242x2688.png",
"minimum-system-version" : "12.0",
"orientation" : "portrait",
"scale" : "3x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "2688h",
"filename" : "ScummVM-splash-2688x1242.png",
"minimum-system-version" : "12.0",
"orientation" : "landscape",
"scale" : "3x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "1792h",
"filename" : "ScummVM-splash-828x1792.png",
"minimum-system-version" : "12.0",
"orientation" : "portrait",
"scale" : "2x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "1792h",
"filename" : "ScummVM-splash-1792x828.png",
"minimum-system-version" : "12.0",
"orientation" : "landscape",
"scale" : "2x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "2436h",
"filename" : "ScummVM-splash-1125x2436.png",
"minimum-system-version" : "11.0",
"orientation" : "portrait",
"scale" : "3x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "2436h",
"filename" : "ScummVM-splash-2436x1125.png",
"minimum-system-version" : "11.0",
"orientation" : "landscape",
"scale" : "3x"
},
{ {
"extent" : "full-screen", "extent" : "full-screen",
"idiom" : "iphone", "idiom" : "iphone",

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 KiB

After

Width:  |  Height:  |  Size: 86 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View file

@ -24,6 +24,8 @@
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>2.1.0git</string> <string>2.1.0git</string>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>UIApplicationExitsOnSuspend</key> <key>UIApplicationExitsOnSuspend</key>
<false/> <false/>
<key>UIDeviceFamily</key> <key>UIDeviceFamily</key>