project_files/HedgewarsMobile/Classes/TeamConfigViewController.m
changeset 3551 d4de36b3801a
parent 3547 02875b1145b7
child 3625 9f1d79e01a60
equal deleted inserted replaced
3550:149416b948fc 3551:d4de36b3801a
    23 -(void) viewDidLoad {
    23 -(void) viewDidLoad {
    24     [super viewDidLoad];
    24     [super viewDidLoad];
    25     
    25     
    26     CGSize screenSize = [[UIScreen mainScreen] bounds].size;
    26     CGSize screenSize = [[UIScreen mainScreen] bounds].size;
    27     self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44);
    27     self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44);
       
    28     isFirstLoad = YES;
    28 }
    29 }
    29 
    30 
    30 -(void) viewWillAppear:(BOOL)animated {
    31 -(void) viewWillAppear:(BOOL)animated {
    31     [super viewWillAppear:animated];
    32     [super viewWillAppear:animated];
    32 
    33 
    33     // integer representation of various color (defined in SquareButtonView)
    34     // avoid overwriting selected teams when returning on this view
    34     NSUInteger colors[6] = { 4421353, 4100897, 10632635, 16749353, 14483456, 7566195 };
    35     if (isFirstLoad) {
    35     NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:TEAMS_DIRECTORY() error:NULL];
    36         // integer representation of various color (defined in SquareButtonView)
    36     NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:[contentsOfDir count]];
    37         NSUInteger colors[6] = { 4421353, 4100897, 10632635, 16749353, 14483456, 7566195 };
    37     for (int i = 0; i < [contentsOfDir count]; i++) {
    38         NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:TEAMS_DIRECTORY() error:NULL];
    38         NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
    39         NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:[contentsOfDir count]];
    39                                                                   [contentsOfDir objectAtIndex:i],@"team",
    40         for (int i = 0; i < [contentsOfDir count]; i++) {
    40                                                                   [NSNumber numberWithInt:4],@"number",
    41             NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
    41                                                                   [NSNumber numberWithInt:colors[i%6]],@"color",nil];
    42                                          [contentsOfDir objectAtIndex:i],@"team",
    42         [array addObject:dict];
    43                                          [NSNumber numberWithInt:4],@"number",
    43         [dict release];
    44                                          [NSNumber numberWithInt:colors[i%6]],@"color",nil];
       
    45             [array addObject:dict];
       
    46             [dict release];
       
    47         }
       
    48         self.listOfTeams = array;
       
    49         [array release];
       
    50         
       
    51         NSMutableArray *emptyArray = [[NSMutableArray alloc] initWithObjects:nil];
       
    52         self.listOfSelectedTeams = emptyArray;
       
    53         [emptyArray release];
       
    54         isFirstLoad = NO;
    44     }
    55     }
    45     self.listOfTeams = array;
       
    46     [array release];
       
    47     
       
    48     NSMutableArray *emptyArray = [[NSMutableArray alloc] initWithObjects:nil];
       
    49     self.listOfSelectedTeams = emptyArray;
       
    50     [emptyArray release];
       
    51 
       
    52     [self.tableView reloadData];
    56     [self.tableView reloadData];
    53 }
    57 }
    54 
    58 
    55 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    59 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    56     return rotationManager(interfaceOrientation);
    60     return rotationManager(interfaceOrientation);