diff --git a/.gitignore b/.gitignore index e1f440cd..aa5ee1ae 100644 --- a/.gitignore +++ b/.gitignore @@ -85,3 +85,4 @@ build/iOS/deps/* !build/iOS/deps/*.sh build/iOS/assets.zip build/iOS/worlds.zip +build/iOS/Ads diff --git a/build/iOS/Ads/ads.h b/build/iOS/Ads/ads.h new file mode 100644 index 00000000..e69de29b diff --git a/build/iOS/Ads/ads.mm b/build/iOS/Ads/ads.mm new file mode 100644 index 00000000..e69de29b diff --git a/build/iOS/Ads/readme.txt b/build/iOS/Ads/readme.txt new file mode 100644 index 00000000..99878e4a --- /dev/null +++ b/build/iOS/Ads/readme.txt @@ -0,0 +1,5 @@ +1. Uncomment relevant lines in Podfile and run "pod update" + +2. Copy ads.mm and ads.h here (overwrite) + +3. Enable Ads in src/client/clientlauncher.cpp diff --git a/build/iOS/MultiCraft/MultiCraft.xcodeproj/project.pbxproj b/build/iOS/MultiCraft/MultiCraft.xcodeproj/project.pbxproj index 71e8d5c1..f6963448 100644 --- a/build/iOS/MultiCraft/MultiCraft.xcodeproj/project.pbxproj +++ b/build/iOS/MultiCraft/MultiCraft.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ EB4367AE23CAD13A43ADF4B1 /* libPods-MultiCraft.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8758CE009FCB7E91F4C84C28 /* libPods-MultiCraft.a */; }; F81F6BE51DDC7D99000B9E21 /* libintl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F81F6BE41DDC7D99000B9E21 /* libintl.a */; }; + F84D3A951DE79AB400ADE1A0 /* ads.mm in Sources */ = {isa = PBXBuildFile; fileRef = F84D3A941DE79AB400ADE1A0 /* ads.mm */; }; F85722891DDC74B700308383 /* libluajit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F85722881DDC74B700308383 /* libluajit.a */; }; F8E6C4E71DCA3B7900F64426 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F8E6C4E51DCA3B7900F64426 /* Main.storyboard */; }; F8E6C4E91DCA3B7900F64426 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F8E6C4E81DCA3B7900F64426 /* Assets.xcassets */; }; @@ -213,6 +214,8 @@ 32528F14AAB9EA0E9CAB8526 /* Pods-MultiCraft.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MultiCraft.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-MultiCraft/Pods-MultiCraft.debug.xcconfig"; sourceTree = ""; }; 8758CE009FCB7E91F4C84C28 /* libPods-MultiCraft.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-MultiCraft.a"; sourceTree = BUILT_PRODUCTS_DIR; }; F81F6BE41DDC7D99000B9E21 /* libintl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libintl.a; path = ../deps/intl/libintl.a; sourceTree = ""; }; + F84D3A931DE79AB400ADE1A0 /* ads.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ads.h; path = ../../Ads/ads.h; sourceTree = ""; }; + F84D3A941DE79AB400ADE1A0 /* ads.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ads.mm; path = ../../Ads/ads.mm; sourceTree = ""; }; F85722881DDC74B700308383 /* libluajit.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libluajit.a; path = ../deps/luajit/lib/libluajit.a; sourceTree = ""; }; F8E6C4D91DCA3B7900F64426 /* MultiCraft.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MultiCraft.app; sourceTree = BUILT_PRODUCTS_DIR; }; F8E6C4E61DCA3B7900F64426 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; @@ -667,6 +670,15 @@ name = Pods; sourceTree = ""; }; + F84D3A921DE79AA500ADE1A0 /* Ads */ = { + isa = PBXGroup; + children = ( + F84D3A931DE79AB400ADE1A0 /* ads.h */, + F84D3A941DE79AB400ADE1A0 /* ads.mm */, + ); + name = Ads; + sourceTree = ""; + }; F8E6C4D01DCA3B7900F64426 = { isa = PBXGroup; children = ( @@ -702,6 +714,7 @@ F8E6C4DC1DCA3B7900F64426 /* Supporting Files */ = { isa = PBXGroup; children = ( + F84D3A921DE79AA500ADE1A0 /* Ads */, F8E6C4F31DCA3EA400F64426 /* ioswrap.h */, F8E6C4F41DCA3EA400F64426 /* ioswrap.m */, F8E6C7E01DCA4EB300F64426 /* assets.zip */, @@ -1354,6 +1367,7 @@ F8E6C6351DCA3F9900F64426 /* mapgen_valleys.cpp in Sources */, F8E6C6101DCA3F9900F64426 /* environment.cpp in Sources */, F8E6C64E1DCA3F9900F64426 /* rollback_interface.cpp in Sources */, + F84D3A951DE79AB400ADE1A0 /* ads.mm in Sources */, F8E6C6301DCA3F9900F64426 /* mapgen_fractal.cpp in Sources */, F8E6C6441DCA3F9900F64426 /* noise.cpp in Sources */, F8E6C7BB1DCA428800F64426 /* numeric.cpp in Sources */, diff --git a/build/iOS/MultiCraft/MultiCraft/Info.plist b/build/iOS/MultiCraft/MultiCraft/Info.plist index 118e586c..b12026d6 100644 --- a/build/iOS/MultiCraft/MultiCraft/Info.plist +++ b/build/iOS/MultiCraft/MultiCraft/Info.plist @@ -46,5 +46,10 @@ UIViewControllerBasedStatusBarAppearance + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + diff --git a/build/iOS/Podfile b/build/iOS/Podfile index a281e1fc..f2b796e1 100644 --- a/build/iOS/Podfile +++ b/build/iOS/Podfile @@ -4,4 +4,8 @@ platform :ios, '8.0' target 'MultiCraft' do pod 'SSZipArchive' pod 'SDVersion' + + #pod 'Appodeal/Core', '~> 1.1' + #pod 'Appodeal/Interstitial', '1.3.3' + #pod 'Appodeal/Video', '1.3.3' end diff --git a/build/iOS/deps/irrlicht.sh b/build/iOS/deps/irrlicht.sh index 5aee1005..dd48f589 100755 --- a/build/iOS/deps/irrlicht.sh +++ b/build/iOS/deps/irrlicht.sh @@ -8,7 +8,7 @@ cd irrlicht-src/ if [ ! -f .patched ]; then - for p in touchcount unscaled dblfreefix; do + for p in touchcount unscaled dblfreefix viewcontroller; do patch -p0 <../../patches/irrlicht-$p.patch done touch .patched diff --git a/build/iOS/patches/irrlicht-viewcontroller.patch b/build/iOS/patches/irrlicht-viewcontroller.patch new file mode 100644 index 00000000..7b68596f --- /dev/null +++ b/build/iOS/patches/irrlicht-viewcontroller.patch @@ -0,0 +1,26 @@ +--- source/Irrlicht/CIrrDeviceiOS.h.bak 2016-11-21 17:59:52.000000000 +0100 ++++ source/Irrlicht/CIrrDeviceiOS.h 2016-11-21 18:06:06.000000000 +0100 +@@ -61,6 +61,8 @@ + + virtual E_DEVICE_TYPE getType() const _IRR_OVERRIDE_; + ++ void *getViewController(); ++ + private: + void createWindow(); + void createViewAndDriver(); +--- source/Irrlicht/CIrrDeviceiOS.mm.bak 2016-11-21 18:00:26.000000000 +0100 ++++ source/Irrlicht/CIrrDeviceiOS.mm 2016-11-21 18:06:35.000000000 +0100 +@@ -687,6 +687,12 @@ + return EIDT_IOS; + } + ++ void *CIrrDeviceiOS::getViewController() ++ { ++ SIrrDeviceiOSDataStorage* dataStorage = static_cast(DataStorage); ++ return (__bridge void*) dataStorage->ViewController; ++ } ++ + void CIrrDeviceiOS::createWindow() + { + if (CreationParams.DriverType != video::EDT_NULL) diff --git a/src/client/clientlauncher.cpp b/src/client/clientlauncher.cpp index 8572dfc0..f6c234ae 100644 --- a/src/client/clientlauncher.cpp +++ b/src/client/clientlauncher.cpp @@ -34,6 +34,17 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "fontengine.h" #include "clientlauncher.h" +#if 0 // toggle to 1 for ads +#define ADS +#include "ads.h" +namespace irr { + class CIrrDeviceiOS : public IrrlichtDevice { + public: + void *getViewController(); + }; +} +#endif + /* mainmenumanager.h */ gui::IGUIEnvironment *guienv = NULL; @@ -238,6 +249,9 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args) receiver->m_touchscreengui = new TouchScreenGUI(device, receiver); g_touchscreengui = receiver->m_touchscreengui; #endif +#ifdef ADS + ads_enable(true); +#endif the_game( kill, @@ -262,6 +276,9 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args) g_touchscreengui = NULL; receiver->m_touchscreengui = NULL; #endif +#ifdef ADS + ads_enable(false); +#endif } //try catch (con::PeerNotFoundException &e) { @@ -498,9 +515,17 @@ void ClientLauncher::main_menu(MainMenuData *menudata) device->getCursorControl()->setVisible(true); #endif +#ifdef ADS + ads_enable(true); +#endif + /* show main menu */ GUIEngine mymenu(device, guiroot, &g_menumgr, smgr, menudata, *kill); +#ifdef ADS + ads_enable(false); +#endif + smgr->clear(); /* leave scene manager in a clean state */ } @@ -556,6 +581,12 @@ bool ClientLauncher::create_engine_device() if (device) { porting::initIrrlicht(device); } +#ifdef ADS + if (device) { + CIrrDeviceiOS* dev = (CIrrDeviceiOS*) device; + ads_startup(dev->getViewController()); + } +#endif return device != NULL; }