project_files/HedgewarsMobile/Classes/TeamConfigViewController.m
changeset 6908 896ed2afcfb8
parent 6832 fae8fd118da9
child 8441 a00b0fa0dbd7
equal deleted inserted replaced
6907:a2f9a9a62dc5 6908:896ed2afcfb8
    66     NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:TEAMS_DIRECTORY() error:NULL];
    66     NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:TEAMS_DIRECTORY() error:NULL];
    67     if ([self.cachedContentsOfDir isEqualToArray:contentsOfDir] == NO) {
    67     if ([self.cachedContentsOfDir isEqualToArray:contentsOfDir] == NO) {
    68         self.cachedContentsOfDir = contentsOfDir;
    68         self.cachedContentsOfDir = contentsOfDir;
    69         NSArray *colors = [HWUtils teamColors];
    69         NSArray *colors = [HWUtils teamColors];
    70         NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:[contentsOfDir count]];
    70         NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:[contentsOfDir count]];
    71         for (int i = 0; i < [contentsOfDir count]; i++) {
    71         for (NSUInteger i = 0; i < [contentsOfDir count]; i++) {
    72             NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
    72             NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
    73                                          [contentsOfDir objectAtIndex:i],@"team",
    73                                          [contentsOfDir objectAtIndex:i],@"team",
    74                                          [NSNumber numberWithInt:4],@"number",
    74                                          [NSNumber numberWithInt:4],@"number",
    75                                          [colors objectAtIndex:i%[colors count]],@"color",nil];
    75                                          [colors objectAtIndex:i%[colors count]],@"color",nil];
    76             [array addObject:dict];
    76             [array addObject:dict];
   222 
   222 
   223 
   223 
   224 #pragma mark -
   224 #pragma mark -
   225 #pragma mark Table view delegate
   225 #pragma mark Table view delegate
   226 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   226 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   227     NSInteger row = [indexPath row];
   227     NSUInteger row = [indexPath row];
   228     NSInteger section = [indexPath section];
   228     NSUInteger section = [indexPath section];
   229 
   229 
   230     if (section == 1 && [self.listOfAllTeams count] > row) {
   230     if (section == 1 && [self.listOfAllTeams count] > row) {
   231         [self.listOfSelectedTeams addObject:[self.listOfAllTeams objectAtIndex:row]];
   231         [self.listOfSelectedTeams addObject:[self.listOfAllTeams objectAtIndex:row]];
   232         [self.listOfAllTeams removeObjectAtIndex:row];
   232         [self.listOfAllTeams removeObjectAtIndex:row];
   233 
   233 
   252         cell.imageView.image = [UIImage drawHogsRepeated:[newNumber intValue]];
   252         cell.imageView.image = [UIImage drawHogsRepeated:[newNumber intValue]];
   253     }
   253     }
   254 }
   254 }
   255 
   255 
   256 -(void) holdAction:(NSString *)content onTable:(UITableView *)aTableView {
   256 -(void) holdAction:(NSString *)content onTable:(UITableView *)aTableView {
   257     NSInteger row;
   257     NSUInteger row;
   258     for (row = 0; row < [self.listOfSelectedTeams count]; row++) {
   258     for (row = 0; row < [self.listOfSelectedTeams count]; row++) {
   259         NSDictionary *dict = [self.listOfSelectedTeams objectAtIndex:row];
   259         NSDictionary *dict = [self.listOfSelectedTeams objectAtIndex:row];
   260         if ([content isEqualToString:[[dict objectForKey:@"team"] stringByDeletingPathExtension]])
   260         if ([content isEqualToString:[[dict objectForKey:@"team"] stringByDeletingPathExtension]])
   261             break;
   261             break;
   262     }
   262     }