project_files/HedgewarsMobile/Classes/TeamConfigViewController.m
changeset 3703 12d17c6e8855
parent 3697 d5b30d6373fc
child 3739 97cf933e5bd2
equal deleted inserted replaced
3701:8c449776ebe6 3703:12d17c6e8855
    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     isFirstLoad = YES;
       
    29     
       
    30     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
       
    31         [self.tableView setBackgroundView:nil];
       
    32         self.view.backgroundColor = [UIColor clearColor];
       
    33         self.tableView.separatorColor = UICOLOR_HW_YELLOW_BODER;
       
    34     }
       
    35     self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    29 }
    36 }
    30 
    37 
    31 -(void) viewWillAppear:(BOOL)animated {
    38 -(void) viewWillAppear:(BOOL)animated {
    32     [super viewWillAppear:animated];
    39     [super viewWillAppear:animated];
    33 
    40 
    72         return [listOfSelectedTeams count] ;
    79         return [listOfSelectedTeams count] ;
    73     else
    80     else
    74         return [listOfTeams count];
    81         return [listOfTeams count];
    75 }
    82 }
    76 
    83 
    77 -(NSString *)tableView:(UITableView *)aTableView titleForHeaderInSection:(NSInteger)section {
       
    78     if (section == 0)
       
    79         return NSLocalizedString(@"Playing Teams",@"");
       
    80     else
       
    81         return NSLocalizedString(@"Available Teams",@"");
       
    82 }
       
    83 
       
    84 // Customize the appearance of table view cells.
    84 // Customize the appearance of table view cells.
    85 -(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    85 -(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    86     static NSString *CellIdentifier0 = @"Cell0";
    86     static NSString *CellIdentifier0 = @"Cell0";
    87     static NSString *CellIdentifier1 = @"Cell1";
    87     static NSString *CellIdentifier1 = @"Cell1";
    88     NSInteger section = [indexPath section];
    88     NSInteger section = [indexPath section];
   104             [squareButton release];
   104             [squareButton release];
   105 
   105 
   106             UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(12+88+7+36+7, 10, 250, 25)];
   106             UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(12+88+7+36+7, 10, 250, 25)];
   107             label.textAlignment = UITextAlignmentLeft;
   107             label.textAlignment = UITextAlignmentLeft;
   108             label.backgroundColor = [UIColor clearColor];
   108             label.backgroundColor = [UIColor clearColor];
   109             label.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize] + 2];
   109             label.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
       
   110             label.textColor = UICOLOR_HW_YELLOW_TEXT;
   110             label.tag = LABEL_TAG;
   111             label.tag = LABEL_TAG;
   111             [cell.contentView addSubview:label];
   112             [cell.contentView addSubview:label];
   112             [label release];
   113             [label release];
   113         }
   114         }
   114 
   115 
   122         numberButton.ownerDictionary = selectedRow;
   123         numberButton.ownerDictionary = selectedRow;
   123 
   124 
   124         SquareButtonView *squareButton = (SquareButtonView *)[cell viewWithTag:SQUAREBUTTON_TAG];
   125         SquareButtonView *squareButton = (SquareButtonView *)[cell viewWithTag:SQUAREBUTTON_TAG];
   125         [squareButton selectColor:[[selectedRow objectForKey:@"color"] intValue]];
   126         [squareButton selectColor:[[selectedRow objectForKey:@"color"] intValue]];
   126         squareButton.ownerDictionary = selectedRow;
   127         squareButton.ownerDictionary = selectedRow;
   127         if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
       
   128             cellLabel.textColor = [UIColor colorWithRed:(CGFloat)0xFE/255 green:(CGFloat)0xCB/255 blue:0 alpha:1];
       
   129         }
       
   130     } else {
   128     } else {
   131         cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier1];
   129         cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier1];
   132         if (cell == nil)
   130         if (cell == nil)
   133             cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] autorelease];
   131             cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] autorelease];
   134 
   132 
   135         cell.textLabel.text = [[[listOfTeams objectAtIndex:[indexPath row]] objectForKey:@"team"] stringByDeletingPathExtension];
   133         cell.textLabel.text = [[[listOfTeams objectAtIndex:[indexPath row]] objectForKey:@"team"] stringByDeletingPathExtension];
   136         if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
   134     }
   137             cell.textLabel.textColor = [UIColor colorWithRed:(CGFloat)0xFE/255 green:(CGFloat)0xCB/255 blue:0 alpha:1 ];
   135 
   138         }
   136     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
   139     }
   137         cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT;
   140 
   138         cell.backgroundColor = [UIColor blackColor];
       
   139     }
       
   140     
   141     return cell;
   141     return cell;
   142 }
   142 }
   143 
   143 
       
   144 -(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
       
   145     return 40.0;
       
   146 }
       
   147 
       
   148 -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
       
   149     NSString *fileToLoad;
       
   150     if (section == 0) 
       
   151         fileToLoad = @"PlayingTeamsLabel.png";
       
   152     else
       
   153         fileToLoad = @"AvailableTeamsLabel.png";
       
   154     
       
   155     UIImage *img = [[UIImage alloc] initWithContentsOfFile:fileToLoad];
       
   156     UIImageView *imgView = [[[UIImageView alloc] initWithImage:img] autorelease];
       
   157     [img release];
       
   158 
       
   159     return imgView;
       
   160 }
       
   161 
       
   162 /*
       
   163 -(NSString *)tableView:(UITableView *)aTableView titleForHeaderInSection:(NSInteger)section {
       
   164     if (section == 0)
       
   165         return NSLocalizedString(@"Playing Teams",@"");
       
   166     else
       
   167         return NSLocalizedString(@"Available Teams",@"");
       
   168 }
       
   169 */
   144 
   170 
   145 #pragma mark -
   171 #pragma mark -
   146 #pragma mark Table view delegate
   172 #pragma mark Table view delegate
   147 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   173 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   148     NSInteger row = [indexPath row];
   174     NSInteger row = [indexPath row];