project_files/HedgewarsMobile/Classes/StatsPageViewController.m
changeset 5976 306cedbeb213
parent 5208 878e551f0b4a
child 5982 283be2ca54a7
equal deleted inserted replaced
5975:c3a8cab64fcb 5976:306cedbeb213
    71 
    71 
    72 -(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    72 -(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    73     static NSString *CellIdentifier0 = @"Cell0";
    73     static NSString *CellIdentifier0 = @"Cell0";
    74     NSInteger section = [indexPath section];
    74     NSInteger section = [indexPath section];
    75     NSInteger row = [indexPath row];
    75     NSInteger row = [indexPath row];
    76     NSString *imgString = @"";
    76     NSString *imgName = @"";
       
    77     NSString *imgPath = BTN_DIRECTORY();
    77 
    78 
    78     UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier0];
    79     UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier0];
    79     if (cell == nil)
    80     if (cell == nil)
    80         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier0] autorelease];
    81         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier0] autorelease];
    81 
    82 
    82     if (section == 0) {         // winning team
    83     if (section == 0) {         // winning team
    83         imgString = @"StatsStar";
    84         imgName = @"star";
       
    85         imgPath = [[NSBundle mainBundle] resourcePath];
    84         cell.textLabel.text = [self.statsArray objectAtIndex:1];
    86         cell.textLabel.text = [self.statsArray objectAtIndex:1];
    85         cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT;
    87         cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT;
    86     } else if (section == 1) {  // teams ranking
    88     } else if (section == 1) {  // teams ranking
    87         // color, # kills, teamname
    89         // color, # kills, teamname
    88         NSArray *info = [[[self.statsArray objectAtIndex:0] objectAtIndex:row] componentsSeparatedByString:@" "];
    90         NSArray *info = [[[self.statsArray objectAtIndex:0] objectAtIndex:row] componentsSeparatedByString:@" "];
    90         cell.textLabel.textColor = [UIColor colorWithRed:((color >> 16) & 0xFF)/255.0f
    92         cell.textLabel.textColor = [UIColor colorWithRed:((color >> 16) & 0xFF)/255.0f
    91                                                    green:((color >> 8) & 0xFF)/255.0f
    93                                                    green:((color >> 8) & 0xFF)/255.0f
    92                                                     blue:(color & 0xFF)/255.0f
    94                                                     blue:(color & 0xFF)/255.0f
    93                                                    alpha:1.0f];
    95                                                    alpha:1.0f];
    94         cell.textLabel.text = [NSString stringWithFormat:@"%d. %@ (%@ kills)", row+1, [info objectAtIndex:2], [info objectAtIndex:1]];
    96         cell.textLabel.text = [NSString stringWithFormat:@"%d. %@ (%@ kills)", row+1, [info objectAtIndex:2], [info objectAtIndex:1]];
    95         imgString = [NSString stringWithFormat:@"StatsMedal%d",row+1];
    97         imgName = [NSString stringWithFormat:@"StatsMedal%d",row+1];
    96     } else if (section == 2) {  // general info
    98     } else if (section == 2) {  // general info
    97         imgString = @"iconDamage";
    99         imgName = @"iconDamage";
    98         cell.textLabel.text = [self.statsArray objectAtIndex:row + 2];
   100         cell.textLabel.text = [self.statsArray objectAtIndex:row + 2];
    99         cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT;
   101         cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT;
   100     } else {                    // exit button
   102     } else {                    // exit button
   101         cell.textLabel.text = NSLocalizedString(@"Done",@"");
   103         cell.textLabel.text = NSLocalizedString(@"Done",@"");
   102         cell.textLabel.textColor = [UIColor whiteColor];
   104         cell.textLabel.textColor = [UIColor whiteColor];
   103         cell.accessoryView = nil;
   105         cell.accessoryView = nil;
   104         cell.imageView.image = nil;
   106         cell.imageView.image = nil;
   105     }
   107     }
   106 
   108 
   107     UIImage *img = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.png",BTN_DIRECTORY(),imgString]];
   109     NSString *imgString = [[NSString alloc] initWithFormat:@"%@/%@.png",imgPath,imgName];
       
   110     UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgString];
       
   111     [imgString release];
   108     UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
   112     UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
   109     cell.imageView.image = img;
   113     cell.imageView.image = img;
   110     [img release];
   114     [img release];
   111     cell.accessoryView = imgView;
   115     cell.accessoryView = imgView;
   112     [imgView release];
   116     [imgView release];