project_files/HedgewarsMobile/Classes/GameSetup.m
changeset 3634 93d260c96635
parent 3626 19f78afa0188
child 3642 fb39fecca350
equal deleted inserted replaced
3632:8e1bd8b5780e 3634:93d260c96635
   365     NSString *localeString = [[NSString alloc] initWithFormat:@"%@.txt", [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]];
   365     NSString *localeString = [[NSString alloc] initWithFormat:@"%@.txt", [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]];
   366     CGRect screenBounds = [[UIScreen mainScreen] bounds];
   366     CGRect screenBounds = [[UIScreen mainScreen] bounds];
   367     NSString *wSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.width];
   367     NSString *wSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.width];
   368     NSString *hSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.height];
   368     NSString *hSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.height];
   369     const char **gameArgs = (const char**) malloc(sizeof(char *) * 10);
   369     const char **gameArgs = (const char**) malloc(sizeof(char *) * 10);
   370 
   370     NSInteger tmpQuality;
       
   371     
   371     size_t size;
   372     size_t size;
   372     // Set 'oldp' parameter to NULL to get the size of the data returned so we can allocate appropriate amount of space
   373     // Set 'oldp' parameter to NULL to get the size of the data returned so we can allocate appropriate amount of space
   373     sysctlbyname("hw.machine", NULL, &size, NULL, 0); 
   374     sysctlbyname("hw.machine", NULL, &size, NULL, 0); 
   374     char *name = (char *)malloc(sizeof(char) * size);
   375     char *name = (char *)malloc(sizeof(char) * size);
   375     // Get the platform name
   376     // Get the platform name
   377     NSString *modelId = [[NSString alloc] initWithUTF8String:name];
   378     NSString *modelId = [[NSString alloc] initWithUTF8String:name];
   378     free(name);
   379     free(name);
   379 
   380 
   380     if ([modelId hasPrefix:@"iPhone1"] ||                                   // = iPhone or iPhone 3G
   381     if ([modelId hasPrefix:@"iPhone1"] ||                                   // = iPhone or iPhone 3G
   381         [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"])   // = iPod Touch or iPod Touch 2G
   382         [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"])   // = iPod Touch or iPod Touch 2G
   382         gameArgs[9] = "3";                          // rqLowRes & rqBlurryLand & rqKillFlakes
   383         tmpQuality = 0x00000001 | 0x00000002 | 0x00000040;  // rqLowRes | rqBlurryLand | rqKillFlakes
   383     else if ([modelId hasPrefix:@"iPhone2"] ||                              // = iPhone 3GS
   384     else if ([modelId hasPrefix:@"iPhone2"] ||                              // = iPhone 3GS
   384              [modelId hasPrefix:@"iPod3"])                                  // = iPod Touch 3G
   385              [modelId hasPrefix:@"iPod3"])                                  // = iPod Touch 3G
   385             gameArgs[9] = "2";                      // rqBlurryLand & rqKillFlakes
   386             tmpQuality = 0x00000002 | 0x00000040;           // rqBlurryLand | rqKillFlakes 
   386         else if ([modelId hasPrefix:@"iPad1"])                              // = iPad
   387         else if ([modelId hasPrefix:@"iPad1"])                              // = iPad
   387                 gameArgs[9] = "1";                  // rqBlurryLand
   388                 tmpQuality = 0x00000002;                    // rqBlurryLand
   388             else                                                            // = everything else
   389             else                                                            // = everything else
   389                 gameArgs[9] = "0";                  // full quality
   390                 tmpQuality = 0;                             // full quality
       
   391     if (![modelId hasPrefix:@"iPad"])                                       // = disable tooltips unless iPad
       
   392         tmpQuality = tmpQuality | 0x00000400;
   390     [modelId release];
   393     [modelId release];
   391     
   394     
   392     
   395     gameArgs[9] = [[[NSNumber numberWithInteger:tmpQuality] stringValue] UTF8String];
       
   396 
   393     // prevents using an empty nickname
   397     // prevents using an empty nickname
   394     NSString *username;
   398     NSString *username;
   395     NSString *originalUsername = [self.systemSettings objectForKey:@"username"];
   399     NSString *originalUsername = [self.systemSettings objectForKey:@"username"];
   396     if ([originalUsername length] == 0)
   400     if ([originalUsername length] == 0)
   397         username = [[NSString alloc] initWithFormat:@"MobileUser-%@",ipcString];
   401         username = [[NSString alloc] initWithFormat:@"MobileUser-%@",ipcString];