| 1 | /* |
| 2 | Copyright 2017-2017 Michalis Kamburelis. |
| 3 | |
| 4 | This file is part of "Castle Game Engine". |
| 5 | |
| 6 | "Castle Game Engine" is free software; see the file COPYING.txt, |
| 7 | included in the "Castle Game Engine" distribution, |
| 8 | for details about the copyright. |
| 9 | |
| 10 | "Castle Game Engine" is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | |
| 14 | ---------------------------------------------------------------------------- |
| 15 | */ |
| 16 | |
| 17 | #import "OpenGLController.h" |
| 18 | #import "AvailableProduct.h" |
| 19 | |
| 20 | /* Base class for all Castle Game Engine iOS application services. */ |
| 21 | @interface ServiceAbstract : NSObject { |
| 22 | } |
| 23 | |
| 24 | /* Called when AppDelegate receives applicationDidEnterBackground. */ |
| 25 | - (void)applicationDidEnterBackground; |
| 26 | |
| 27 | /* Called when AppDelegate receives application:didFinishLaunchingWithOptions: message. */ |
| 28 | - (void)application:(UIApplication *) application didFinishLaunchingWithOptions:(NSDictionary *) launchOptions; |
| 29 | |
| 30 | /* Called when AppDelegate receives applicationDidBecomeActive: message. */ |
| 31 | - (void)applicationDidBecomeActive:(UIApplication *)application; |
| 32 | |
| 33 | /* Called when AppDelegate receives application:openURL:options message. */ |
| 34 | - (BOOL)application:(UIApplication *)app |
| 35 | openURL:(NSURL *)url |
| 36 | options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options; |
| 37 | |
| 38 | /* Try handling this message. Returns TRUE if handled. */ |
| 39 | - (bool)messageReceived:(NSArray* )message; |
| 40 | |
| 41 | /* Send the message to Pascal. */ |
| 42 | - (void)messageSend:(NSArray* )message; |
| 43 | |
| 44 | /* Convert string to boolean when receiving message in messageReceive. */ |
| 45 | - (bool)stringToBool:(NSString* )value; |
| 46 | |
| 47 | /* Convert boolean to string when sending the message in messageSend. */ |
| 48 | - (NSString*)boolToString:(bool)value; |
| 49 | |
| 50 | /* Notification that a purchase just happened. */ |
| 51 | - (void)onPurchase:(AvailableProduct*) product |
| 52 | withTransaction:(SKPaymentTransaction*) transaction; |
| 53 | |
| 54 | @property (nonatomic, retain) UIWindow *window; |
| 55 | @property (nonatomic, retain) OpenGLController *mainController; |
| 56 | |
| 57 | @end |
| 58 | |
| 59 | /* Return non-nil version of the string. |
| 60 | In case value is nil, returns zero-length non-nil string version, @"". |
| 61 | |
| 62 | This is particularly useful because when NSArray cannot hold nil. |
| 63 | So this is unsafe, in case myString may be nil: |
| 64 | |
| 65 | @[myString] |
| 66 | |
| 67 | This is always safe: |
| 68 | |
| 69 | @[stringNonNil(myString)] |
| 70 | */ |
| 71 | NSString* stringNonNil(NSString* value); |