project_files/HedgewarsMobile/Classes/CreationChamber.m
changeset 6103 55ecfbf834e3
parent 5984 6fd40d866342
child 6104 117bdf4e7af9
equal deleted inserted replaced
6102:97565ab4afe9 6103:55ecfbf834e3
    20 
    20 
    21 
    21 
    22 #import "CreationChamber.h"
    22 #import "CreationChamber.h"
    23 #import "hwconsts.h"
    23 #import "hwconsts.h"
    24 
    24 
    25 void createSettings () {
    25 
       
    26 @implementation CreationChamber
       
    27 
       
    28 #pragma mark Settings
       
    29 +(void) createSettings {
    26     NSUserDefaults *settings = [NSUserDefaults standardUserDefaults];
    30     NSUserDefaults *settings = [NSUserDefaults standardUserDefaults];
    27     [settings setObject:[NSNumber numberWithBool:NO] forKey:@"alternate"];
    31     [settings setObject:[NSNumber numberWithBool:NO] forKey:@"alternate"];
    28     [settings setObject:[NSNumber numberWithBool:YES] forKey:@"music"];
    32     [settings setObject:[NSNumber numberWithBool:YES] forKey:@"music"];
    29     [settings setObject:[NSNumber numberWithBool:YES] forKey:@"sound"];
    33     [settings setObject:[NSNumber numberWithBool:YES] forKey:@"sound"];
    30     [settings setObject:[NSNumber numberWithBool:NO] forKey:@"classic_menu"];
    34     [settings setObject:[NSNumber numberWithBool:NO] forKey:@"classic_menu"];
    37         [settings setObject:@"" forKey:@"password"];
    41         [settings setObject:@"" forKey:@"password"];
    38 
    42 
    39     [settings synchronize];
    43     [settings synchronize];
    40 }
    44 }
    41 
    45 
    42 void createTeamNamed (NSString *nameWithoutExt) {
    46 #pragma mark Teams
       
    47 +(void) createTeamNamed:(NSString *)nameWithoutExt {
       
    48     [CreationChamber createTeamNamed:nameWithoutExt ofType:0 controlledByAI:NO];
       
    49 }
       
    50 
       
    51 +(void) createTeamNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type {
       
    52     [CreationChamber createTeamNamed:nameWithoutExt ofType:type controlledByAI:NO];
       
    53 }
       
    54 
       
    55 +(void) createTeamNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type controlledByAI:(BOOL) flag {
    43     NSString *teamsDirectory = TEAMS_DIRECTORY();
    56     NSString *teamsDirectory = TEAMS_DIRECTORY();
    44 
    57 
    45     if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) {
    58     if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) {
    46         [[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory
    59         [[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory
    47                                   withIntermediateDirectories:NO
    60                                   withIntermediateDirectories:NO
    78     [theTeam writeToFile:teamFile atomically:YES];
    91     [theTeam writeToFile:teamFile atomically:YES];
    79     [teamFile release];
    92     [teamFile release];
    80     [theTeam release];
    93     [theTeam release];
    81 }
    94 }
    82 
    95 
    83 void createWeaponNamed (NSString *nameWithoutExt, int type) {
    96 #pragma mark Weapons
       
    97 +(void) createWeaponNamed:(NSString *)nameWithoutExt {
       
    98     [CreationChamber createWeaponNamed:nameWithoutExt ofType:0];
       
    99 }
       
   100 
       
   101 +(void) createWeaponNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type {
    84     NSString *weaponsDirectory = WEAPONS_DIRECTORY();
   102     NSString *weaponsDirectory = WEAPONS_DIRECTORY();
    85 
   103 
    86     if (![[NSFileManager defaultManager] fileExistsAtPath: weaponsDirectory]) {
   104     if (![[NSFileManager defaultManager] fileExistsAtPath: weaponsDirectory]) {
    87         [[NSFileManager defaultManager] createDirectoryAtPath:weaponsDirectory
   105         [[NSFileManager defaultManager] createDirectoryAtPath:weaponsDirectory
    88                                   withIntermediateDirectories:NO
   106                                   withIntermediateDirectories:NO
   148     [theWeapon writeToFile:weaponFile atomically:YES];
   166     [theWeapon writeToFile:weaponFile atomically:YES];
   149     [weaponFile release];
   167     [weaponFile release];
   150     [theWeapon release];
   168     [theWeapon release];
   151 }
   169 }
   152 
   170 
   153 void createSchemeNamed (NSString *nameWithoutExt, int type) {
   171 #pragma mark Schemes
       
   172 +(void) createSchemeNamed:(NSString *)nameWithoutExt {
       
   173     [CreationChamber createSchemeNamed:nameWithoutExt ofType:0];
       
   174 }
       
   175 
       
   176 +(void) createSchemeNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type {
   154     NSString *schemesDirectory = SCHEMES_DIRECTORY();
   177     NSString *schemesDirectory = SCHEMES_DIRECTORY();
   155 
   178 
   156     if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) {
   179     if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) {
   157         [[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory
   180         [[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory
   158                                   withIntermediateDirectories:NO
   181                                   withIntermediateDirectories:NO
   285     
   308     
   286     [theScheme writeToFile:schemeFile atomically:YES];
   309     [theScheme writeToFile:schemeFile atomically:YES];
   287     [schemeFile release];
   310     [schemeFile release];
   288     [theScheme release];
   311     [theScheme release];
   289 }
   312 }
       
   313 
       
   314 @end