432 |
432 |
433 #pragma mark - |
433 #pragma mark - |
434 #pragma mark Setting methods |
434 #pragma mark Setting methods |
435 // returns an array of c-strings that are read by engine at startup |
435 // returns an array of c-strings that are read by engine at startup |
436 -(const char **)getSettings: (NSString *)recordFile { |
436 -(const char **)getSettings: (NSString *)recordFile { |
|
437 NSInteger width, height; |
437 NSString *ipcString = [[NSString alloc] initWithFormat:@"%d", ipcPort]; |
438 NSString *ipcString = [[NSString alloc] initWithFormat:@"%d", ipcPort]; |
438 NSString *localeString = [[NSString alloc] initWithFormat:@"%@.txt", [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]]; |
439 NSString *localeString = [[NSString alloc] initWithFormat:@"%@.txt", [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]]; |
439 CGRect screenBounds = [[UIScreen mainScreen] bounds]; |
440 NSString *rotation; |
440 NSString *wSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.width]; |
441 if ([[UIScreen screens] count] > 1) { |
441 NSString *hSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.height]; |
442 CGRect screenBounds = [[[UIScreen screens] objectAtIndex:1] bounds]; |
|
443 width = (int) screenBounds.size.width; |
|
444 height = (int) screenBounds.size.height; |
|
445 rotation = @"0"; |
|
446 } else { |
|
447 CGRect screenBounds = [[UIScreen mainScreen] bounds]; |
|
448 width = (int) screenBounds.size.height; |
|
449 height = (int) screenBounds.size.width; |
|
450 rotation = @"-90"; |
|
451 } |
|
452 |
|
453 NSString *horizontalSize = [[NSString alloc] initWithFormat:@"%d", width]; |
|
454 NSString *verticalSize = [[NSString alloc] initWithFormat:@"%d", height]; |
442 const char **gameArgs = (const char**) malloc(sizeof(char *) * 10); |
455 const char **gameArgs = (const char**) malloc(sizeof(char *) * 10); |
443 NSInteger tmpQuality; |
456 NSInteger tmpQuality; |
444 |
457 |
445 NSString *modelId = modelType(); |
458 NSString *modelId = modelType(); |
446 if ([modelId hasPrefix:@"iPhone1"] || // = iPhone or iPhone 3G |
459 if ([modelId hasPrefix:@"iPhone1"] || // = iPhone or iPhone 3G |
451 tmpQuality = 0x00000002 | 0x00000040; // rqBlurryLand | rqKillFlakes |
464 tmpQuality = 0x00000002 | 0x00000040; // rqBlurryLand | rqKillFlakes |
452 else if ([modelId hasPrefix:@"iPad1"]) // = iPad |
465 else if ([modelId hasPrefix:@"iPad1"]) // = iPad |
453 tmpQuality = 0x00000002; // rqBlurryLand |
466 tmpQuality = 0x00000002; // rqBlurryLand |
454 else // = everything else |
467 else // = everything else |
455 tmpQuality = 0; // full quality |
468 tmpQuality = 0; // full quality |
456 if (![modelId hasPrefix:@"iPad"]) // = disable tooltips unless iPad |
469 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) // = disable tooltips on phone |
457 tmpQuality = tmpQuality | 0x00000400; |
470 tmpQuality = tmpQuality | 0x00000400; |
458 |
471 |
459 // prevents using an empty nickname |
472 // prevents using an empty nickname |
460 NSString *username; |
473 NSString *username; |
461 NSString *originalUsername = [self.systemSettings objectForKey:@"username"]; |
474 NSString *originalUsername = [self.systemSettings objectForKey:@"username"]; |
463 username = [[NSString alloc] initWithFormat:@"MobileUser-%@",ipcString]; |
476 username = [[NSString alloc] initWithFormat:@"MobileUser-%@",ipcString]; |
464 else |
477 else |
465 username = [[NSString alloc] initWithString:originalUsername]; |
478 username = [[NSString alloc] initWithString:originalUsername]; |
466 |
479 |
467 gameArgs[ 0] = [ipcString UTF8String]; //ipcPort |
480 gameArgs[ 0] = [ipcString UTF8String]; //ipcPort |
468 gameArgs[ 1] = [wSize UTF8String]; //cScreenHeight |
481 gameArgs[ 1] = [horizontalSize UTF8String]; //cScreenWidth |
469 gameArgs[ 2] = [hSize UTF8String]; //cScreenWidth |
482 gameArgs[ 2] = [verticalSize UTF8String]; //cScreenHeight |
470 gameArgs[ 3] = [[[NSNumber numberWithInteger:tmpQuality] stringValue] UTF8String]; //quality |
483 gameArgs[ 3] = [[[NSNumber numberWithInteger:tmpQuality] stringValue] UTF8String]; //quality |
471 gameArgs[ 4] = "en.txt";//[localeString UTF8String]; //cLocaleFName |
484 gameArgs[ 4] = "en.txt";//[localeString UTF8String]; //cLocaleFName |
472 gameArgs[ 5] = [username UTF8String]; //UserNick |
485 gameArgs[ 5] = [username UTF8String]; //UserNick |
473 gameArgs[ 6] = [[[self.systemSettings objectForKey:@"sound"] stringValue] UTF8String]; //isSoundEnabled |
486 gameArgs[ 6] = [[[self.systemSettings objectForKey:@"sound"] stringValue] UTF8String]; //isSoundEnabled |
474 gameArgs[ 7] = [[[self.systemSettings objectForKey:@"music"] stringValue] UTF8String]; //isMusicEnabled |
487 gameArgs[ 7] = [[[self.systemSettings objectForKey:@"music"] stringValue] UTF8String]; //isMusicEnabled |
475 gameArgs[ 8] = [[[self.systemSettings objectForKey:@"alternate"] stringValue] UTF8String]; //cAltDamage |
488 gameArgs[ 8] = [[[self.systemSettings objectForKey:@"alternate"] stringValue] UTF8String]; //cAltDamage |
476 gameArgs[ 9] = NULL; //unused |
489 gameArgs[ 9] = [rotation UTF8String]; //rotateQt |
477 gameArgs[10] = [recordFile UTF8String]; //recordFileName |
490 gameArgs[10] = [recordFile UTF8String]; //recordFileName |
478 |
491 |
479 [wSize release]; |
492 [verticalSize release]; |
480 [hSize release]; |
493 [horizontalSize release]; |
481 [localeString release]; |
494 [localeString release]; |
482 [ipcString release]; |
495 [ipcString release]; |
483 [username release]; |
496 [username release]; |
484 return gameArgs; |
497 return gameArgs; |
485 } |
498 } |