# HG changeset patch # User antonc27 # Date 1439664546 -7200 # Node ID 41cfa8edf02f10a6a3f3da95b984ed5cad09bc3e # Parent fa3d227fb308ef200b77b7a167aa41d7651798d9# Parent 29d0a5c04b3be1f2968ec158f0248f281bdfb5c9 Merge with ios-rus-localization diff -r 29d0a5c04b3b -r 41cfa8edf02f hedgewars/hwLibrary.pas --- a/hedgewars/hwLibrary.pas Sat Aug 15 17:08:50 2015 +0200 +++ b/hedgewars/hwLibrary.pas Sat Aug 15 20:49:06 2015 +0200 @@ -120,9 +120,6 @@ {$ELSE} exports RunEngine, -{$IFDEF MOBILE} - GenLandPreview, -{$ENDIF} LoadLocaleWrapper, HW_versionInfo, HW_versionString, diff -r 29d0a5c04b3b -r 41cfa8edf02f hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Sat Aug 15 17:08:50 2015 +0200 +++ b/hedgewars/hwengine.pas Sat Aug 15 20:49:06 2015 +0200 @@ -44,9 +44,6 @@ procedure preInitEverything(); procedure initEverything(complete:boolean); procedure freeEverything(complete:boolean); -{$IFDEF MOBILE} -procedure GenLandPreview; cdecl; export; -{$ENDIF MOBILE} implementation {$ELSE} @@ -543,8 +540,12 @@ end; /////////////////////////////////////////////////////////////////////////////// -procedure GenLandPreview;{$IFDEF MOBILE} cdecl; export;{$ENDIF MOBILE} +procedure GenLandPreview; +{$IFDEF MOBILE} +var Preview: TPreview; +{$ELSE} var Preview: TPreviewAlpha; +{$ENDIF MOBILE} begin initEverything(false); @@ -553,7 +554,11 @@ TryDo(InitStepsFlags = cifRandomize, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true); ScriptOnPreviewInit; +{$IFDEF MOBILE} + GenPreview(Preview); +{$ELSE} GenPreviewAlpha(Preview); +{$ENDIF MOBILE} WriteLnToConsole('Sending preview...'); SendIPCRaw(@Preview, sizeof(Preview)); SendIPCRaw(@MaxHedgehogs, sizeof(byte)); diff -r 29d0a5c04b3b -r 41cfa8edf02f project_files/HedgewarsMobile/Classes/GameConfigViewController.m --- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Sat Aug 15 17:08:50 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Sat Aug 15 20:49:06 2015 +0200 @@ -325,7 +325,7 @@ if (IS_IPAD() == NO) return; - [self updateUIForInterfaceOrientation:toInterfaceOrientation]; + [self updateiPadUIForInterfaceOrientation:toInterfaceOrientation]; [self.schemeWeaponConfigViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; @@ -335,7 +335,7 @@ } } -- (void)updateUIForInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +- (void)updateiPadUIForInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { if ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)) { @@ -363,9 +363,12 @@ // if (IS_IPAD()) // [NSThread detachNewThreadSelector:@selector(loadNiceHogs) toTarget:self withObject:nil]; - // we assume here what 'statusBarOrientation' will never be changed manually! - UIInterfaceOrientation currentOrientation = [[UIApplication sharedApplication] statusBarOrientation]; - [self updateUIForInterfaceOrientation:currentOrientation]; + if (IS_IPAD()) + { + // we assume here what 'statusBarOrientation' will never be changed manually! + UIInterfaceOrientation currentOrientation = [[UIApplication sharedApplication] statusBarOrientation]; + [self updateiPadUIForInterfaceOrientation:currentOrientation]; + } [self.mapConfigViewController viewWillAppear:animated]; [self.teamConfigViewController viewWillAppear:animated]; diff -r 29d0a5c04b3b -r 41cfa8edf02f project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m --- a/project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m Sat Aug 15 17:08:50 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m Sat Aug 15 20:49:06 2015 +0200 @@ -83,11 +83,33 @@ serverQuit = YES; } - // launch the preview here so that we're sure the tcp channel is open - pthread_t thread_id; - pthread_create(&thread_id, NULL, (void *(*)(void *))GenLandPreview, (void *)port); - pthread_detach(thread_id); - + // launch the preview in background here so that we're sure the tcp channel is open + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), ^{ + NSString *ipcString = [[NSString alloc] initWithFormat:@"%d", port]; + NSString *documentsDirectory = DOCUMENTS_FOLDER(); + + NSMutableArray *gameParameters = [[NSMutableArray alloc] initWithObjects: + @"--internal", + @"--port", ipcString, + @"--user-prefix", documentsDirectory, + @"--landpreview", + nil]; + [ipcString release]; + + int argc = [gameParameters count]; + const char **argv = (const char **)malloc(sizeof(const char*)*argc); + for (int i = 0; i < argc; i++) + argv[i] = strdup([[gameParameters objectAtIndex:i] UTF8String]); + [gameParameters release]; + + RunEngine(argc, argv); + + // cleanup + for (int i = 0; i < argc; i++) + free((void *)argv[i]); + free(argv); + }); + DLog(@"Waiting for a client on port %d", port); while (!serverQuit) { /* This check the sd if there is a pending connection. @@ -135,7 +157,7 @@ // http://developer.apple.com/mac/library/qa/qa2001/qa1037.html CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceGray(); - CGContextRef bitmapImage = CGBitmapContextCreate(unpackedMap, 256, 128, 8, 256, colorspace, kCGImageAlphaNone); + CGContextRef bitmapImage = CGBitmapContextCreate(unpackedMap, 256, 128, 8, 256, colorspace, (CGBitmapInfo)kCGImageAlphaNone); CGColorSpaceRelease(colorspace); CGImageRef previewCGImage = CGBitmapContextCreateImage(bitmapImage); diff -r 29d0a5c04b3b -r 41cfa8edf02f project_files/HedgewarsMobile/Classes/PascalImports.h --- a/project_files/HedgewarsMobile/Classes/PascalImports.h Sat Aug 15 17:08:50 2015 +0200 +++ b/project_files/HedgewarsMobile/Classes/PascalImports.h Sat Aug 15 20:49:06 2015 +0200 @@ -29,7 +29,6 @@ */ void RunEngine(const int argc, const char *argv[]); - void GenLandPreview(void); void LoadLocaleWrapper(const char *filename); void HW_versionInfo(int *protoNum, char **versionStr);