iOS added files (#42)

master
sfan5 2016-11-05 23:14:22 +01:00 committed by Maksim Gamarnik
parent 60c5679a07
commit faafd4d0cc
25 changed files with 2718 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,98 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "AppIcon-120.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "AppIcon-180.png",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "AppIcon-76.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "AppIcon-152.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "AppIcon-167.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" 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="11106"/>
<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="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</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="1" green="1" blue="1" 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>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIRequiresFullScreen</key>
<true/>
<key>UIStatusBarHidden</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
</array>
</dict>
</plist>

View File

@ -0,0 +1,23 @@
#ifndef ioswrap_h
#define ioswrap_h
#ifdef __cplusplus
extern "C" {
#endif
enum {
PATH_DOCUMENTS,
PATH_LIBRARY_SUPPORT,
PATH_LIBRARY_CACHE,
};
void ioswrap_log(const char *message);
void ioswrap_paths(int type, char *dest, size_t destlen);
void ioswrap_assets(void); // extracts assets.zip to PATH_LIBRARY_SUPPORT
void ioswrap_size(unsigned int *dest);
#ifdef __cplusplus
}
#endif
#endif /* ioswrap_h */

View File

@ -0,0 +1,58 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <SSZipArchive/SSZipArchive.h>
#include "ioswrap.h"
void ioswrap_log(const char *message)
{
NSLog(@"%s", message);
}
void ioswrap_paths(int type, char *dest, size_t destlen)
{
NSArray *paths;
if (type == PATH_DOCUMENTS)
paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
else if (type == PATH_LIBRARY_SUPPORT || type == PATH_LIBRARY_CACHE)
paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
else
return;
NSString *path = paths.firstObject;
const char *path_c = path.UTF8String;
if (type == PATH_DOCUMENTS)
snprintf(dest, destlen, "%s", path_c);
else if (type == PATH_LIBRARY_SUPPORT)
snprintf(dest, destlen, "%s/Application Support", path_c);
else // type == PATH_LIBRARY_CACHE
snprintf(dest, destlen, "%s/Caches", path_c);
}
void ioswrap_assets()
{
const struct { const char *name; int path; } assets[] = {
{ .name = "assets", .path = PATH_LIBRARY_SUPPORT },
{ .name = "worlds", .path = PATH_DOCUMENTS },
{ NULL, 0 },
};
char buf[256];
for(int i = 0; assets[i].name != NULL; i++) {
ioswrap_paths(assets[i].path, buf, sizeof(buf));
NSString *destpath = [NSString stringWithUTF8String:buf];
NSString *zippath = [[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:assets[i].name] ofType:@"zip"];
NSLog(@"%s: extract %@ to %@", assets[i].name, zippath, destpath);
[SSZipArchive unzipFileAtPath:zippath toDestination:destpath];
}
}
void ioswrap_size(unsigned int *dest)
{
CGSize bounds = [[UIScreen mainScreen] bounds].size;
CGFloat scale = [[UIScreen mainScreen] scale];
dest[0] = bounds.width * scale;
dest[1] = bounds.height * scale;
}

7
build/iOS/Podfile Normal file
View File

@ -0,0 +1,7 @@
project 'MultiCraft/MultiCraft.xcodeproj'
platform :ios, '8.0'
target 'MultiCraft' do
pod 'SSZipArchive'
pod 'SDVersion'
end

22
build/iOS/Start.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash -e
echo
echo "Starting build MultiCraft for iOS..."
echo
echo "Build Libraries:"
./libraries.sh
echo
echo "Creating Assets:"
./assets.sh
echo
echo "Install CocoaPods:"
pod install
echo
echo "All done! You can continue in Xcode!"

12
build/iOS/appicon.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash -e
# Generates different AppIcon images with correct dimensions
# (brew package: imagemagick)
SIZES="76 120 152 167 180"
SRCFILE=../android/src/main/res/drawable-xhdpi/ic_launcher.png
DSTDIR=MultiCraft/MultiCraft/Assets.xcassets/AppIcon.appiconset
for sz in $SIZES; do
echo "Creating ${sz}x${sz} icon"
convert -resize ${sz}x${sz} $SRCFILE $DSTDIR/AppIcon-${sz}.png
done

37
build/iOS/assets.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash -e
if [ ! -d MultiCraft/MultiCraft.xcodeproj ]; then
echo "Run this in build/iOS"
exit 1
fi
FOLDER=$(pwd)
DEST=$(mktemp -d)
for dir in builtin textures; do
cp -r ../../$dir $DEST/$dir
done
mkdir -p $DEST/fonts
cp ../../fonts/retrovillenc.ttf $DEST/fonts/ # no PNG fonts because freetype
mkdir -p $DEST/games
cp -r ../../games/default $DEST/games/default
find $DEST -type d -name '.git' -print0 | xargs -0 -- rm -r
find $DEST -type f -name '.git*' -delete
find $DEST -type f -name '.DS_Store' -delete
echo "Creating assets.zip"
ZIPDEST=$FOLDER/assets.zip
rm -f $ZIPDEST
cd $DEST; zip -9r $ZIPDEST -- *
cd $FOLDER; rm -rf $DEST
###########
echo "Creating worlds.zip"
ZIPDEST=$FOLDER/worlds.zip
rm -f $ZIPDEST
cd ../..; zip -9r $ZIPDEST -- worlds

25
build/iOS/deps/freetype.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash -e
. ../sdk.sh
FREETYPE_VERSION=2.7
if [ ! -d freetype-src ]; then
wget http://download.savannah.gnu.org/releases/freetype/freetype-$FREETYPE_VERSION.tar.gz
tar -xzvf freetype-$FREETYPE_VERSION.tar.gz
mv freetype-$FREETYPE_VERSION freetype-src
rm freetype-$FREETYPE_VERSION.tar.gz
fi
cd freetype-src
CC=$IOS_CC CFLAGS=$IOS_FLAGS \
PKG_CONFIG=/bin/false \
./configure --host=arm-apple-darwin --prefix=/ \
--disable-shared --enable-static \
--with-png=no
make -j$(sysctl -n hw.ncpu)
mkdir -p ../freetype
make DESTDIR=$PWD/../freetype install
echo "freetype build successful"

30
build/iOS/deps/irrlicht.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash -e
. ../sdk.sh
[ ! -d irrlicht-src ] && \
svn co svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es irrlicht-src
cd irrlicht-src/
if [ ! -f .patched ]; then
for p in touchcount unscaled dblfreefix; do
patch -p0 <../../patches/irrlicht-$p.patch
done
touch .patched
fi
cd source/Irrlicht
xcodebuild build \
-project Irrlicht.xcodeproj \
-scheme Irrlicht_iOS \
-destination generic/platform=iOS
cd ../..
[ -d ../irrlicht ] && rm -r ../irrlicht
mkdir -p ../irrlicht
cp lib/iOS/libIrrlicht.a ../irrlicht/
cp -r include ../irrlicht/include
cp -r media ../irrlicht/media
echo "Irrlicht build successful"

26
build/iOS/deps/leveldb.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash -e
. ../sdk.sh
LEVELDB_VERSION=1.19
if [ ! -d leveldb-src ]; then
wget https://github.com/google/leveldb/archive/v$LEVELDB_VERSION.tar.gz
tar -xzvf v$LEVELDB_VERSION.tar.gz
mv leveldb-$LEVELDB_VERSION leveldb-src
rm v$LEVELDB_VERSION.tar.gz
fi
cd leveldb-src
# prevent Makefile from fiddling with our flags
sed -i .old 's|^ifeq.*IOS.*|ifeq (0, 1)|g' Makefile
CC="$IOS_CC $IOS_FLAGS" CXX="$IOS_CC $IOS_FLAGS" \
TARGET_OS=IOS \
make -j$(sysctl -n hw.ncpu) out-static/libleveldb.a
[ -d ../leveldb ] && rm -r ../leveldb
mkdir -p ../leveldb/lib
cp -r include/ ../leveldb/include
cp out-static/libleveldb.a ../leveldb/lib
echo "leveldb build successful"

24
build/iOS/deps/libcurl.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash -e
. ../sdk.sh
CURL_VERSION=7.50.3
if [ ! -d libcurl-src ]; then
wget https://curl.haxx.se/download/curl-$CURL_VERSION.tar.gz
tar -xzvf curl-$CURL_VERSION.tar.gz
mv curl-$CURL_VERSION libcurl-src
rm curl-$CURL_VERSION.tar.gz
fi
cd libcurl-src
CC=$IOS_CC CFLAGS=$IOS_FLAGS \
./configure --host=arm-apple-darwin --prefix=/ \
--disable-shared --enable-static \
--with-darwinssl
make -j$(sysctl -n hw.ncpu)
mkdir -p ../libcurl
make DESTDIR=$PWD/../libcurl install
echo "libcurl build successful"

23
build/iOS/deps/libogg.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash -e
. ../sdk.sh
OGG_VERSION=1.3.2
if [ ! -d libogg-src ]; then
wget http://downloads.xiph.org/releases/ogg/libogg-$OGG_VERSION.tar.gz
tar -xzvf libogg-$OGG_VERSION.tar.gz
mv libogg-$OGG_VERSION libogg-src
rm libogg-$OGG_VERSION.tar.gz
fi
cd libogg-src
CC=$IOS_CC CFLAGS=$IOS_FLAGS \
./configure --host=arm-apple-darwin --prefix=/ \
--disable-shared --enable-static
make -j$(sysctl -n hw.ncpu)
mkdir -p ../libogg
make DESTDIR=$PWD/../libogg install
echo "libogg build successful"

24
build/iOS/deps/libvorbis.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash -e
. ../sdk.sh
VORBIS_VERSION=1.3.5
if [ ! -d libvorbis-src ]; then
wget http://downloads.xiph.org/releases/vorbis/libvorbis-$VORBIS_VERSION.tar.gz
tar -xzvf libvorbis-$VORBIS_VERSION.tar.gz
mv libvorbis-$VORBIS_VERSION libvorbis-src
rm libvorbis-$VORBIS_VERSION.tar.gz
fi
cd libvorbis-src
CC=$IOS_CC CFLAGS=$IOS_FLAGS \
./configure --host=arm-apple-darwin --prefix=/ \
--disable-shared --enable-static \
--with-ogg=$PWD/../libogg
make -j$(sysctl -n hw.ncpu)
mkdir -p ../libvorbis
make DESTDIR=$PWD/../libvorbis install
echo "libvorbis build successful"

12
build/iOS/libraries.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash -e
cd deps
./irrlicht.sh
./libogg.sh
./libvorbis.sh # depends on libogg
./leveldb.sh
./freetype.sh
echo
echo "All libraries were built!"

View File

@ -0,0 +1,12 @@
--- source/Irrlicht/COpenGLCoreCacheHandler.h.orig 2016-10-25 15:42:40.000000000 +0200
+++ source/Irrlicht/COpenGLCoreCacheHandler.h 2016-10-25 15:52:13.000000000 +0200
@@ -115,9 +115,6 @@
}
Texture[index] = static_cast<const TOpenGLTexture*>(texture);
-
- if (prevTexture)
- prevTexture->drop();
}
status = true;

View File

@ -0,0 +1,52 @@
--- include/IEventReceiver.h.orig 2016-10-21 00:07:27.000000000 +0200
+++ include/IEventReceiver.h 2016-10-21 00:08:40.000000000 +0200
@@ -417,6 +417,9 @@
// Y position of simple touch.
s32 Y;
+ // Number of current touches
+ s32 touchedCount;
+
//! Type of touch event.
ETOUCH_INPUT_EVENT Event;
};
--- source/Irrlicht/CIrrDeviceiOS.mm.orig 2016-10-21 00:07:45.000000000 +0200
+++ source/Irrlicht/CIrrDeviceiOS.mm 2016-10-21 00:10:07.000000000 +0200
@@ -202,6 +202,7 @@
irr::SEvent ev;
ev.EventType = irr::EET_TOUCH_INPUT_EVENT;
ev.TouchInput.Event = irr::ETIE_PRESSED_DOWN;
+ ev.TouchInput.touchedCount = [touches count];
for (UITouch* touch in touches)
{
@@ -220,7 +221,8 @@
{
irr::SEvent ev;
ev.EventType = irr::EET_TOUCH_INPUT_EVENT;
- ev.TouchInput.Event = irr::ETIE_MOVED;
+ ev.TouchInput.Event = irr::ETIE_MOVED;
+ ev.TouchInput.touchedCount = [touches count];
for (UITouch* touch in touches)
{
@@ -239,7 +241,8 @@
{
irr::SEvent ev;
ev.EventType = irr::EET_TOUCH_INPUT_EVENT;
- ev.TouchInput.Event = irr::ETIE_LEFT_UP;
+ ev.TouchInput.Event = irr::ETIE_LEFT_UP;
+ ev.TouchInput.touchedCount = [touches count];
for (UITouch* touch in touches)
{
@@ -258,7 +261,8 @@
{
irr::SEvent ev;
ev.EventType = irr::EET_TOUCH_INPUT_EVENT;
- ev.TouchInput.Event = irr::ETIE_LEFT_UP;
+ ev.TouchInput.Event = irr::ETIE_LEFT_UP;
+ ev.TouchInput.touchedCount = [touches count];
for (UITouch* touch in touches)
{

View File

@ -0,0 +1,11 @@
--- source/Irrlicht/CIrrDeviceiOS.mm.orig 2016-10-21 13:27:51.000000000 +0200
+++ source/Irrlicht/CIrrDeviceiOS.mm 2016-10-21 13:28:14.000000000 +0200
@@ -186,7 +186,7 @@
if (self)
{
Device = device;
- Scale = ([self respondsToSelector:@selector(setContentScaleFactor:)]) ? [[UIScreen mainScreen] scale] : 1.f;
+ Scale = 1.f;
}
return self;

10
build/iOS/sdk.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash -e
# This file sets the appropiate compiler and flags for compiling for iOS without XCode
sdk=iphoneos
export IOS_COMPILER=$(xcrun --sdk $sdk --find clang)
export IOS_CC=$IOS_COMPILER
export IOS_CXX=$IOS_COMPILER
export IOS_FLAGS="-isysroot $(xcrun --sdk $sdk --show-sdk-path) -arch armv7 -arch arm64"

52
src/porting_ios.cpp Normal file
View File

@ -0,0 +1,52 @@
#include <string>
#include "porting.h"
#include "config.h"
#include "ioswrap.h"
namespace porting {
void initializePathsiOS() {
char buf[128];
ioswrap_paths(PATH_DOCUMENTS, buf, sizeof(buf));
path_user = std::string(buf);
ioswrap_paths(PATH_LIBRARY_SUPPORT, buf, sizeof(buf));
path_share = std::string(buf);
ioswrap_paths(PATH_LIBRARY_CACHE, buf, sizeof(buf));
path_cache = std::string(buf);
}
void copyAssets() {
ioswrap_assets();
}
float getDisplayDensity() {
return 1.0;
}
v2u32 getDisplaySize() {
static bool firstrun = true;
static v2u32 retval;
if(firstrun) {
unsigned int values[2];
ioswrap_size(values);
retval.X = values[0];
retval.Y = values[1];
firstrun = false;
}
return retval;
}
}
extern int real_main(int argc, char *argv[]);
void irrlicht_main() {
static const char *args[] = {
PROJECT_NAME,
};
real_main(1, (char**) args);
}

13
src/porting_ios.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef __PORTING__IOS_H__
#define __PORTING__IOS_H__
#ifndef __IOS__
#error This file should only be included on iOS
#endif
namespace porting {
void initializePathsiOS();
void copyAssets();
}
#endif

BIN
textures/base/escape.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B