project_files/HedgewarsMobile/Classes/TeamConfigViewController.m
changeset 3917 4c243b1eac97
parent 3829 81db3c85784b
child 3971 5c82ee165ed5
equal deleted inserted replaced
3916:e7d665a4ef42 3917:4c243b1eac97
    38     [super viewDidLoad];
    38     [super viewDidLoad];
    39 
    39 
    40     CGSize screenSize = [[UIScreen mainScreen] bounds].size;
    40     CGSize screenSize = [[UIScreen mainScreen] bounds].size;
    41     self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44);
    41     self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44);
    42     
    42     
    43     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    43     [self.tableView setBackgroundView:nil];
    44         [self.tableView setBackgroundView:nil];
    44     self.view.backgroundColor = [UIColor clearColor];
    45         self.view.backgroundColor = [UIColor clearColor];
    45     self.tableView.separatorColor = UICOLOR_HW_YELLOW_BODER;
    46         self.tableView.separatorColor = UICOLOR_HW_YELLOW_BODER;
       
    47     }
       
    48     self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    46     self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    49 }
    47 }
    50 
    48 
    51 -(void) viewWillAppear:(BOOL)animated {
    49 -(void) viewWillAppear:(BOOL)animated {
    52     [super viewWillAppear:animated];
    50     [super viewWillAppear:animated];
    53 
    51 
    54     NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:TEAMS_DIRECTORY() error:NULL];
    52     NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:TEAMS_DIRECTORY() error:NULL];
    55     // avoid overwriting selected teams when returning on this view
    53     // avoid overwriting selected teams when returning on this view
    56     if ([cachedContentsOfDir isEqualToArray:contentsOfDir] == NO) {
    54     if ([cachedContentsOfDir isEqualToArray:contentsOfDir] == NO) {
    57         // integer representation of various color (defined in SquareButtonView)
    55         NSArray *colors = getAvailableColors();
    58         NSUInteger colors[6] = { 4421353, 4100897, 10632635, 16749353, 14483456, 7566195 };
       
    59         NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:[contentsOfDir count]];
    56         NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:[contentsOfDir count]];
    60         for (int i = 0; i < [contentsOfDir count]; i++) {
    57         for (int i = 0; i < [contentsOfDir count]; i++) {
    61             NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
    58             NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
    62                                          [contentsOfDir objectAtIndex:i],@"team",
    59                                          [contentsOfDir objectAtIndex:i],@"team",
    63                                          [NSNumber numberWithInt:4],@"number",
    60                                          [NSNumber numberWithInt:4],@"number",
    64                                          [NSNumber numberWithInt:colors[i%6]],@"color",nil];
    61                                          [colors objectAtIndex:i%[colors count]],@"color",nil];
    65             [array addObject:dict];
    62             [array addObject:dict];
    66             [dict release];
    63             [dict release];
    67         }
    64         }
    68         self.listOfTeams = array;
    65         self.listOfTeams = array;
    69         [array release];
    66         [array release];
   161             cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] autorelease];
   158             cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] autorelease];
   162 
   159 
   163         cell.textLabel.text = [[[listOfTeams objectAtIndex:[indexPath row]] objectForKey:@"team"] stringByDeletingPathExtension];
   160         cell.textLabel.text = [[[listOfTeams objectAtIndex:[indexPath row]] objectForKey:@"team"] stringByDeletingPathExtension];
   164         cell.accessoryView = nil;
   161         cell.accessoryView = nil;
   165     }
   162     }
   166 
   163     
   167     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
   164     cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT;
   168         cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT;
   165     cell.backgroundColor = [UIColor blackColor];
   169         cell.backgroundColor = [UIColor blackColor];
       
   170     }
       
   171     
   166     
   172     return cell;
   167     return cell;
   173 }
   168 }
   174 
   169 
   175 -(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
   170 -(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
   198     [theView addSubview:theLabel];
   193     [theView addSubview:theLabel];
   199     [theLabel release];
   194     [theLabel release];
   200     return theView;
   195     return theView;
   201 }
   196 }
   202 
   197 
   203 /*
       
   204 -(NSString *)tableView:(UITableView *)aTableView titleForHeaderInSection:(NSInteger)section {
       
   205     if (section == 0)
       
   206         return NSLocalizedString(@"Playing Teams",@"");
       
   207     else
       
   208         return NSLocalizedString(@"Available Teams",@"");
       
   209 }
       
   210 */
       
   211 
       
   212 #pragma mark -
   198 #pragma mark -
   213 #pragma mark Table view delegate
   199 #pragma mark Table view delegate
   214 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   200 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   215     NSInteger row = [indexPath row];
   201     NSInteger row = [indexPath row];
   216     NSInteger section = [indexPath section];
   202     NSInteger section = [indexPath section];