55 } |
55 } |
56 |
56 |
57 #pragma mark - |
57 #pragma mark - |
58 #pragma mark Table view data source |
58 #pragma mark Table view data source |
59 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
59 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
60 return 3; |
60 return 4; |
61 } |
61 } |
62 |
62 |
63 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
63 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
64 if (section == 0 || section == 2) |
64 if (section == 0 || section == 3) |
65 return 1; |
65 return 1; |
|
66 else if (section == 1) |
|
67 return [[self.statsArray objectAtIndex:0] count]; |
66 else |
68 else |
67 return [self.statsArray count] - 1; |
69 return [self.statsArray count] - 2; |
68 } |
70 } |
69 |
71 |
70 -(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
72 -(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
71 static NSString *CellIdentifier0 = @"Cell0"; |
73 static NSString *CellIdentifier0 = @"Cell0"; |
72 NSInteger section = [indexPath section]; |
74 NSInteger section = [indexPath section]; |
73 NSInteger row = [indexPath row]; |
75 NSInteger row = [indexPath row]; |
|
76 NSString *imgString = @""; |
74 |
77 |
75 UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier0]; |
78 UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier0]; |
76 if (cell == nil) |
79 if (cell == nil) |
77 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier0] autorelease]; |
80 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier0] autorelease]; |
78 |
81 |
79 cell.textLabel.textAlignment = UITextAlignmentCenter; |
82 if (section == 0) { // winning team |
80 if (section == 0) { |
83 imgString = @"StatsStar"; |
81 cell.textLabel.text = [self.statsArray objectAtIndex:row]; |
84 cell.textLabel.text = [self.statsArray objectAtIndex:1]; |
82 cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT; |
85 cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT; |
83 } else if (section == 1) { |
86 } else if (section == 1) { // teams ranking |
84 cell.textLabel.text = [self.statsArray objectAtIndex:row + 1]; |
87 // color, # kills, teamname |
|
88 NSArray *info = [[[self.statsArray objectAtIndex:0] objectAtIndex:row] componentsSeparatedByString:@" "]; |
|
89 NSUInteger color = [[info objectAtIndex:0] intValue]; |
|
90 cell.textLabel.textColor = [UIColor colorWithRed:((color >> 16) & 0xFF)/255.0f |
|
91 green:((color >> 8) & 0xFF)/255.0f |
|
92 blue:(color & 0xFF)/255.0f |
|
93 alpha:1.0f]; |
|
94 cell.textLabel.text = [NSString stringWithFormat:@"%d. %@ (%@ kills)", row+1, [info objectAtIndex:2], [info objectAtIndex:1]]; |
|
95 imgString = [NSString stringWithFormat:@"statsMedal%d",row+1]; |
|
96 } else if (section == 2) { // general info |
|
97 imgString = @"iconDamage"; |
|
98 cell.textLabel.text = [self.statsArray objectAtIndex:row + 2]; |
85 cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT; |
99 cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT; |
86 } else { |
100 } else { // exit button |
87 cell.textLabel.text = NSLocalizedString(@"Done",@""); |
101 cell.textLabel.text = NSLocalizedString(@"Done",@""); |
88 cell.textLabel.textColor = [UIColor whiteColor]; |
102 cell.textLabel.textColor = [UIColor whiteColor]; |
|
103 cell.accessoryView = nil; |
|
104 cell.imageView.image = nil; |
89 } |
105 } |
|
106 |
|
107 UIImage *img = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.png",BTN_DIRECTORY(),imgString]]; |
|
108 UIImageView *imgView = [[UIImageView alloc] initWithImage:img]; |
|
109 cell.imageView.image = img; |
|
110 [img release]; |
|
111 cell.accessoryView = imgView; |
|
112 [imgView release]; |
|
113 |
|
114 cell.textLabel.textAlignment = UITextAlignmentCenter; |
90 cell.textLabel.adjustsFontSizeToFitWidth = YES; |
115 cell.textLabel.adjustsFontSizeToFitWidth = YES; |
91 cell.backgroundColor = [UIColor blackColor]; |
116 cell.backgroundColor = [UIColor blackColor]; |
92 cell.selectionStyle = UITableViewCellSelectionStyleNone; |
117 cell.selectionStyle = UITableViewCellSelectionStyleNone; |
93 |
118 |
94 return cell; |
119 return cell; |