project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m
changeset 6078 8c0cc07731e5
parent 6020 c792d4b3e080
child 6083 72c882c0fd0f
equal deleted inserted replaced
6077:d8fa5a85d24f 6078:8c0cc07731e5
    18  * File created on 18/04/2011.
    18  * File created on 18/04/2011.
    19  */
    19  */
    20 
    20 
    21 
    21 
    22 #import "GameInterfaceBridge.h"
    22 #import "GameInterfaceBridge.h"
    23 #import "PascalImports.h"
    23 #import "ServerSetup.h"
    24 #import "EngineProtocolNetwork.h"
    24 #import "EngineProtocolNetwork.h"
    25 #import "OverlayViewController.h"
    25 #import "OverlayViewController.h"
    26 #import "StatsPageViewController.h"
    26 #import "StatsPageViewController.h"
    27 #import "AudioManagerController.h"
    27 #import "AudioManagerController.h"
    28 #import "ObjcExports.h"
    28 #import "ObjcExports.h"
    30 @implementation GameInterfaceBridge
    30 @implementation GameInterfaceBridge
    31 @synthesize parentController, savePath, overlayController, engineProtocol, ipcPort, gameType;
    31 @synthesize parentController, savePath, overlayController, engineProtocol, ipcPort, gameType;
    32 
    32 
    33 -(id) initWithController:(id) viewController {
    33 -(id) initWithController:(id) viewController {
    34     if (self = [super init]) {
    34     if (self = [super init]) {
    35         self.ipcPort = randomPort();
    35         self.ipcPort = [ServerSetup randomPort];
    36         self.gameType = gtNone;
    36         self.gameType = gtNone;
    37         self.savePath = nil;
    37         self.savePath = nil;
    38 
    38 
    39         self.parentController = (UIViewController *)viewController;
    39         self.parentController = (UIViewController *)viewController;
    40         self.engineProtocol = [[EngineProtocolNetwork alloc] initOnPort:self.ipcPort];
    40         self.engineProtocol = [[EngineProtocolNetwork alloc] initOnPort:self.ipcPort];
    77         CGRect screenBounds = [[UIScreen mainScreen] bounds];
    77         CGRect screenBounds = [[UIScreen mainScreen] bounds];
    78         width = (int) screenBounds.size.height;
    78         width = (int) screenBounds.size.height;
    79         height = (int) screenBounds.size.width;
    79         height = (int) screenBounds.size.width;
    80     }
    80     }
    81 
    81 
    82     NSString *horizontalSize = [[NSString alloc] initWithFormat:@"%d", width * (int)getScreenScale()];
    82     NSString *horizontalSize = [[NSString alloc] initWithFormat:@"%d", width * (int)[[UIScreen mainScreen] scale]];
    83     NSString *verticalSize = [[NSString alloc] initWithFormat:@"%d", height * (int)getScreenScale()];
    83     NSString *verticalSize = [[NSString alloc] initWithFormat:@"%d", height * (int)[[UIScreen mainScreen] scale]];
    84     NSString *rotation = [[NSString alloc] initWithString:@"0"];
    84     NSString *rotation = [[NSString alloc] initWithString:@"0"];
    85 
    85 
    86     NSString *modelId = getModelType();
    86     NSString *modelId = [HWUtils modelType];
    87     NSInteger tmpQuality;
    87     NSInteger tmpQuality;
    88     if ([modelId hasPrefix:@"iPhone1"] || [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"])     // = iPhone and iPhone 3G or iPod Touch or iPod Touch 2G
    88     if ([modelId hasPrefix:@"iPhone1"] || [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"])     // = iPhone and iPhone 3G or iPod Touch or iPod Touch 2G
    89         tmpQuality = 0x00000001 | 0x00000002 | 0x00000008 | 0x00000040;                 // rqLowRes | rqBlurryLand | rqSimpleRope | rqKillFlakes
    89         tmpQuality = 0x00000001 | 0x00000002 | 0x00000008 | 0x00000040;                 // rqLowRes | rqBlurryLand | rqSimpleRope | rqKillFlakes
    90     else if ([modelId hasPrefix:@"iPhone2"] || [modelId hasPrefix:@"iPod3"])                                    // = iPhone 3GS or iPod Touch 3G
    90     else if ([modelId hasPrefix:@"iPhone2"] || [modelId hasPrefix:@"iPod3"])                                    // = iPhone 3GS or iPod Touch 3G
    91         tmpQuality = 0x00000002 | 0x00000040;                                           // rqBlurryLand | rqKillFlakes
    91         tmpQuality = 0x00000002 | 0x00000040;                                           // rqBlurryLand | rqKillFlakes
   119     [horizontalSize release];
   119     [horizontalSize release];
   120     [rotation release];
   120     [rotation release];
   121     [localeString release];
   121     [localeString release];
   122     [ipcString release];
   122     [ipcString release];
   123 
   123 
   124     objcExportsInit();
   124     [ObjcExports initialize];
   125 
   125 
   126     // this is the pascal fuction that starts the game, wrapped around isInGame
   126     // this is the pascal fuction that starts the game, wrapped around isInGame
   127     [HedgewarsAppDelegate sharedAppDelegate].isInGame = YES;
   127     [HedgewarsAppDelegate sharedAppDelegate].isInGame = YES;
   128     Game(gameArgs);
   128     Game(gameArgs);
   129     [HedgewarsAppDelegate sharedAppDelegate].isInGame = NO;
   129     [HedgewarsAppDelegate sharedAppDelegate].isInGame = NO;