Kode / Kha

Ultra-portable, high performance, open source multimedia framework.
http://kha.tech
zlib License
1.5k stars 169 forks source link

iOS: Kha doesn't know the correct resolution of iPhone 5S #978

Closed Joncom closed 5 years ago

Joncom commented 5 years ago

This started happening right after fixing: https://github.com/Kode/Kha/issues/969

With the fix:

2019-01-27 21:12:18.308256+0700 Stomp[13795:2774747] [DYMTLInitPlatform] platform initialization successful
backingWitdh/Height: 640, 960
Initializing Haxe libraries
Starting Kore
...

WIthout the fix:

2019-01-27 21:11:36.840948+0700 Stomp[13786:2773984] [DYMTLInitPlatform] platform initialization successful
backingWitdh/Height: 640, 1136
Initializing Haxe libraries
Starting Kore
...
Joncom commented 5 years ago

This results in an ugly black letterbox effect.

RobDangerous commented 5 years ago

Oh boy, guess we don't get around that storyboard crap after all.

Joncom commented 5 years ago

From Discord chat:

Robert: Some weird backwards compatibility measures from Apple I suppose. Robert: It's a common thing in Apple and Microsoft operating systems. if (exists(somenewfilenormallycreatedbyidesinceversionxyz)) return actualdata; else return someoldthing; Robert: But to make sure you could create a regular iOS project, remove the storyboard thing, see if the result is the same.

With unmodified Xcode template:

img_1095

With <key>UILaunchStoryboardName</key> removed from Info.plist:

img_1094

RobDangerous commented 5 years ago

Yay, my theory was accurate.

RobDangerous commented 5 years ago

Oh noes, that means we have to add a storyboard.

RobDangerous commented 5 years ago

Or maybe we can sell that as cinematic mode?

Joncom commented 5 years ago

The following seems to work:

LaunchScreen.storyboard:

<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
    <dependencies>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
    </dependencies>
    <scenes>
        <!--View Controller-->
        <scene sceneID="EHf-IW-A2E">
            <objects>
                <viewController id="01J-lp-oVM" sceneMemberID="viewController">
                    <layoutGuides>
                        <viewControllerLayoutGuide type="top" id="qVO-8e-Oj3"/>
                        <viewControllerLayoutGuide type="bottom" id="Y9C-1R-Fay"/>
                    </layoutGuides>
                    <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                        <color key="backgroundColor" red="0" green="0" blue="0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                    </view>
                </viewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="53" y="375"/>
        </scene>
    </scenes>
</document>
Joncom commented 5 years ago

The solution for this involves:

  1. Reverting commit: https://github.com/Kode/Kore/commit/6e242fee3d20ee43703e27f282caf0323dd66d46
  2. Committing the above file to: Kore/Backends/System/iOS/Sources/Kore/LaunchScreen.storyboard
  3. Applying the following patch to https://github.com/Kode/koremake:
diff --git a/Kha/Kore/Tools/koremake/out/Exporters/XCodeExporter.js b/Kha/Kore/Tools/koremake/out/Exporters/XCodeExporter.js
index af887d7f..d3128ba1 100644
--- a/Kha/Kore/Tools/koremake/out/Exporters/XCodeExporter.js
+++ b/Kha/Kore/Tools/koremake/out/Exporters/XCodeExporter.js
@@ -54,7 +54,7 @@ class File {
         return this.fileid;
     }
     isBuildFile() {
-        return this.filename.endsWith('.c') || this.filename.endsWith('.cpp') || this.filename.endsWith('.m') || this.filename.endsWith('.mm') || this.filename.endsWith('.cc') || this.filename.endsWith('.s') || this.filename.endsWith('S') || this.filename.endsWith('.metal');
+        return this.filename.endsWith('.c') || this.filename.endsWith('.cpp') || this.filename.endsWith('.m') || this.filename.endsWith('.mm') || this.filename.endsWith('.cc') || this.filename.endsWith('.s') || this.filename.endsWith('S') || this.filename.endsWith('.metal') || this.filename.endsWith('.storyboard');
     }
     getName() {
         return this.filename;
@@ -314,6 +314,8 @@ class XCodeExporter extends Exporter_1.Exporter {
         for (let file of files) {
             let filetype = 'unknown';
             let fileencoding = '';
+            if (file.getName().endsWith('.storyboard'))
+                filetype = 'file.storyboard';
             if (file.getName().endsWith('.plist'))
                 filetype = 'text.plist.xml';
             if (file.getName().endsWith('.h'))
diff --git a/Kha/Kore/Tools/koremake/src/Exporters/XCodeExporter.ts b/Kha/Kore/Tools/koremake/src/Exporters/XCodeExporter.ts
index 1235b06e..c1b1abb9 100644
--- a/Kha/Kore/Tools/koremake/src/Exporters/XCodeExporter.ts
+++ b/Kha/Kore/Tools/koremake/src/Exporters/XCodeExporter.ts
@@ -72,7 +72,7 @@ class File {
    }

    isBuildFile() {
-       return this.filename.endsWith('.c') || this.filename.endsWith('.cpp') || this.filename.endsWith('.m') || this.filename.endsWith('.mm') || this.filename.endsWith('.cc') || this.filename.endsWith('.s') || this.filename.endsWith('S') || this.filename.endsWith('.metal');
+       return this.filename.endsWith('.c') || this.filename.endsWith('.cpp') || this.filename.endsWith('.m') || this.filename.endsWith('.mm') || this.filename.endsWith('.cc') || this.filename.endsWith('.s') || this.filename.endsWith('S') || this.filename.endsWith('.metal') || this.filename.endsWith('.storyboard');
    }

    getName() {
@@ -358,6 +358,7 @@ export class XCodeExporter extends Exporter {
        for (let file of files) {
            let filetype = 'unknown';
            let fileencoding = '';
+           if (file.getName().endsWith('.storyboard')) filetype = 'file.storyboard';
            if (file.getName().endsWith('.plist')) filetype = 'text.plist.xml';
            if (file.getName().endsWith('.h')) filetype = 'sourcecode.c.h';
            if (file.getName().endsWith('.m')) filetype = 'sourcecode.c.objc';
Joncom commented 5 years ago

Pull-request containing items 1 and 2: https://github.com/Kode/Kore/pull/360

Joncom commented 5 years ago

Pull-request containing item 3: https://github.com/Kode/koremake/pull/65