equal
deleted
inserted
replaced
23 #pragma mark View lifecycle |
23 #pragma mark View lifecycle |
24 -(void) viewDidLoad { |
24 -(void) viewDidLoad { |
25 [super viewDidLoad]; |
25 [super viewDidLoad]; |
26 |
26 |
27 NSArray *directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:FORTS_DIRECTORY() error:NULL]; |
27 NSArray *directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:FORTS_DIRECTORY() error:NULL]; |
28 NSMutableArray *filteredContents = [[NSMutableArray alloc] initWithCapacity:([directoryContents count] / 2)]; |
28 NSMutableArray *filteredContents = [[NSMutableArray alloc] initWithCapacity:([directoryContents count] / 3)]; |
29 // we need to remove the double entries and the L.png suffix |
29 // we need to remove the double entries and the L.png suffix |
30 for (int i = 0; i < [directoryContents count]; i++) { |
30 for (int i = 0; i < [directoryContents count]; i++) { |
31 if (i % 2) { |
31 if (i % 3 == 1) { |
32 NSString *currentName = [directoryContents objectAtIndex:i]; |
32 NSString *currentName = [directoryContents objectAtIndex:i]; |
33 NSString *correctName = [currentName substringToIndex:([currentName length] - 5)]; |
33 NSString *correctName = [currentName substringToIndex:([currentName length] - 5)]; |
34 [filteredContents addObject:correctName]; |
34 [filteredContents addObject:correctName]; |
35 } |
35 } |
36 } |
36 } |
86 } |
86 } |
87 |
87 |
88 NSString *fortName = [fortArray objectAtIndex:[indexPath row]]; |
88 NSString *fortName = [fortArray objectAtIndex:[indexPath row]]; |
89 cell.textLabel.text = fortName; |
89 cell.textLabel.text = fortName; |
90 |
90 |
91 // this creates a scaled down version of the image |
91 NSString *fortFile = [[NSString alloc] initWithFormat:@"%@/%@-preview.png", FORTS_DIRECTORY(), fortName]; |
92 // TODO: create preview files, scaling is way too slow! |
|
93 NSString *fortFile = [[NSString alloc] initWithFormat:@"%@/%@L.png", FORTS_DIRECTORY(), fortName]; |
|
94 UIImage *fortSprite = [[UIImage alloc] initWithContentsOfFile:fortFile]; |
92 UIImage *fortSprite = [[UIImage alloc] initWithContentsOfFile:fortFile]; |
95 [fortFile release]; |
93 [fortFile release]; |
96 cell.imageView.image = [fortSprite scaleToSize:CGSizeMake(196,196)]; |
94 cell.imageView.image = fortSprite; |
97 [fortSprite release]; |
95 [fortSprite release]; |
98 |
96 |
99 cell.detailTextLabel.text = @"Insert funny description here"; |
97 //cell.detailTextLabel.text = @"Insert funny description here"; |
100 if ([cell.textLabel.text isEqualToString:[self.teamDictionary objectForKey:@"fort"]]) { |
98 if ([cell.textLabel.text isEqualToString:[self.teamDictionary objectForKey:@"fort"]]) { |
101 cell.accessoryType = UITableViewCellAccessoryCheckmark; |
99 cell.accessoryType = UITableViewCellAccessoryCheckmark; |
102 self.lastIndexPath = indexPath; |
100 self.lastIndexPath = indexPath; |
103 } else { |
101 } else { |
104 cell.accessoryType = UITableViewCellAccessoryNone; |
102 cell.accessoryType = UITableViewCellAccessoryNone; |