project_files/HedgewarsMobile/Classes/TeamConfigViewController.m
changeset 4486 2c8e4d859d37
parent 4476 4bf74e158f44
child 4504 8906b2409d97
equal deleted inserted replaced
4485:85695e3d2623 4486:2c8e4d859d37
   251 #pragma mark Table view delegate
   251 #pragma mark Table view delegate
   252 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   252 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   253     NSInteger row = [indexPath row];
   253     NSInteger row = [indexPath row];
   254     NSInteger section = [indexPath section];
   254     NSInteger section = [indexPath section];
   255 
   255 
   256     if (section == 0) {
   256     if (section == 1 && [self.listOfTeams count] > row) {
   257         NSMutableDictionary *selectedRow = [self.listOfSelectedTeams objectAtIndex:[indexPath row]];
       
   258         UITableViewCell *cell = [aTableView cellForRowAtIndexPath:indexPath];
       
   259         SquareButtonView *squareButton = (SquareButtonView *)cell.accessoryView;
       
   260 
       
   261         NSInteger increaseNumber = [[selectedRow objectForKey:@"number"] intValue] + 1;
       
   262         NSNumber *newNumber = [NSNumber numberWithInt:[self filterNumberOfHogs:increaseNumber]];
       
   263         [squareButton setTitle:[newNumber stringValue] forState:UIControlStateNormal];
       
   264         [selectedRow setObject:newNumber forKey:@"number"];
       
   265 
       
   266         cell.imageView.image = [self drawHogsRepeated:[newNumber intValue]];
       
   267         [cell setNeedsLayout];
       
   268     } else {
       
   269         [self.listOfSelectedTeams addObject:[self.listOfTeams objectAtIndex:row]];
   257         [self.listOfSelectedTeams addObject:[self.listOfTeams objectAtIndex:row]];
   270         [self.listOfTeams removeObjectAtIndex:row];
   258         [self.listOfTeams removeObjectAtIndex:row];
   271 
   259 
   272         NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:selectedTeamsCount inSection:0];
   260         NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:selectedTeamsCount inSection:0];
   273         allTeamsCount--;
   261         allTeamsCount--;
   275         [aTableView beginUpdates];
   263         [aTableView beginUpdates];
   276         [aTableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationRight];
   264         [aTableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationRight];
   277         [aTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight];
   265         [aTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight];
   278         [aTableView endUpdates];
   266         [aTableView endUpdates];
   279     }
   267     }
       
   268     if (section == 0 && [self.listOfSelectedTeams count] > row) {
       
   269         NSMutableDictionary *selectedRow = [self.listOfSelectedTeams objectAtIndex:row];
       
   270         UITableViewCell *cell = [aTableView cellForRowAtIndexPath:indexPath];
       
   271         SquareButtonView *squareButton = (SquareButtonView *)cell.accessoryView;
       
   272 
       
   273         NSInteger increaseNumber = [[selectedRow objectForKey:@"number"] intValue] + 1;
       
   274         NSNumber *newNumber = [NSNumber numberWithInt:[self filterNumberOfHogs:increaseNumber]];
       
   275         [squareButton setTitle:[newNumber stringValue] forState:UIControlStateNormal];
       
   276         [selectedRow setObject:newNumber forKey:@"number"];
       
   277 
       
   278         cell.imageView.image = [self drawHogsRepeated:[newNumber intValue]];
       
   279     }
   280 }
   280 }
   281 
   281 
   282 -(void) holdAction:(NSString *)content {
   282 -(void) holdAction:(NSString *)content {
   283     NSInteger row;
   283     NSInteger row;
   284     for (row = 0; row < [self.listOfSelectedTeams count]; row++) {
   284     for (row = 0; row < [self.listOfSelectedTeams count]; row++) {