project_files/HedgewarsMobile/Classes/MainMenuViewController.m
changeset 3738 f10626e18b8a
parent 3737 2ba6ac8a114b
child 3752 73c2d7d5643b
equal deleted inserted replaced
3737:2ba6ac8a114b 3738:f10626e18b8a
    59     // now check if some configuration files are already set; if they are present it means that the current copy must be updated
    59     // now check if some configuration files are already set; if they are present it means that the current copy must be updated
    60     NSError *err = nil;
    60     NSError *err = nil;
    61     NSString *fileToCheck, *teamToCheck, *teamToUpdate, *schemeToCheck, *schemeToUpdate;
    61     NSString *fileToCheck, *teamToCheck, *teamToUpdate, *schemeToCheck, *schemeToUpdate;
    62     NSString *resDir = [[NSBundle mainBundle] resourcePath];
    62     NSString *resDir = [[NSBundle mainBundle] resourcePath];
    63     
    63     
    64     NSString *dirToCheck = [NSString stringWithFormat:@"%@/Settings/", resDir];
    64     NSString *dirToCheck = [NSString stringWithFormat:@"%@/done.txt",DOCUMENTS_FOLDER()];
    65     if ([[NSFileManager defaultManager] fileExistsAtPath:dirToCheck] == YES) {
    65     if ([[NSFileManager defaultManager] fileExistsAtPath:dirToCheck] == NO) {
    66 
    66         DLog(@"Creating necessary files");
       
    67         
    67         // if the settings file is already present, we merge current preferences with the update
    68         // if the settings file is already present, we merge current preferences with the update
    68         fileToCheck = [NSString stringWithFormat:@"%@/Settings/settings.plist",resDir];
    69         fileToCheck = [NSString stringWithFormat:@"%@/Settings/settings.plist",resDir];
    69         if ([[NSFileManager defaultManager] fileExistsAtPath:SETTINGS_FILE()]) {
    70         if ([[NSFileManager defaultManager] fileExistsAtPath:SETTINGS_FILE()]) {
    70             NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()];
    71             NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()];
    71             NSMutableDictionary *update = [[NSMutableDictionary alloc] initWithContentsOfFile:fileToCheck];
    72             NSMutableDictionary *update = [[NSMutableDictionary alloc] initWithContentsOfFile:fileToCheck];
   124             createWeaponNamed(@"Shoppa", 3);
   125             createWeaponNamed(@"Shoppa", 3);
   125             createWeaponNamed(@"Basketball", 4);
   126             createWeaponNamed(@"Basketball", 4);
   126             createWeaponNamed(@"Minefield", 5);
   127             createWeaponNamed(@"Minefield", 5);
   127         }
   128         }
   128         
   129         
   129         // clean this dir so that it doesn't get called again
   130         // create a dummy file so that it doesn't get called again
   130         [[NSFileManager defaultManager] removeItemAtPath:dirToCheck error:&err];
   131         if ([[NSFileManager defaultManager] createFileAtPath:dirToCheck 
       
   132                                                     contents:[NSData dataWithContentsOfFile:SETTINGS_FILE()]
       
   133                                                   attributes:nil])
       
   134             DLog(@"Success");
       
   135         
   131         if (err != nil) 
   136         if (err != nil) 
   132             DLog(@"%@", err);
   137             DLog(@"%@", err);
   133     }
   138     }
   134     
   139     
   135     [super viewDidLoad];
   140     [super viewDidLoad];